Added ability to randomize playlists

Missing videos now show a more verbose error in the logs
This commit is contained in:
Isaac Abadi
2021-07-21 20:03:53 -06:00
parent b56b371ece
commit 9f908aa3fc
6 changed files with 23 additions and 4 deletions

View File

@@ -233,6 +233,9 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
}
this.playlist.push(mediaObject);
}
if (this.db_playlist && this.db_playlist['randomize_order']) {
this.shuffleArray(this.playlist);
}
this.currentItem = this.playlist[this.currentIndex];
this.original_playlist = JSON.stringify(this.playlist);
this.show_player = true;
@@ -409,6 +412,13 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
this.api.playbackRate = speed;
}
shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
// snackbar helper
public openSnackBar(message: string, action: string) {
this.snackBar.open(message, action, {