Player component now remembers previously set volume

Updated name of updatePlaylist->updatePlaylistFiles for clarity and added updatePlaylist route

Added smarter safe download override, will auto activate if subtitle args are included.
This commit is contained in:
Isaac Grynsztein
2020-06-29 19:39:47 -04:00
parent d100e80ccf
commit 86c609c1b2
6 changed files with 61 additions and 10 deletions

View File

@@ -62,6 +62,8 @@ export class PlayerComponent implements OnInit {
downloading = false;
original_volume = null;
@HostListener('window:resize', ['$event'])
onResize(event) {
this.innerWidth = window.innerWidth;
@@ -235,6 +237,12 @@ export class PlayerComponent implements OnInit {
onPlayerReady(api: VgAPI) {
this.api = api;
// checks if volume has been previously set. if so, use that as default
if (localStorage.getItem('player_volume')) {
this.api.volume = parseFloat(localStorage.getItem('player_volume'));
}
setInterval(() => this.saveVolume(this.api), 2000)
this.api.getDefaultMedia().subscriptions.loadedMetadata.subscribe(this.playVideo.bind(this));
this.api.getDefaultMedia().subscriptions.ended.subscribe(this.nextVideo.bind(this));
@@ -243,6 +251,13 @@ export class PlayerComponent implements OnInit {
}
}
saveVolume(api) {
if (this.original_volume !== api.volume) {
localStorage.setItem('player_volume', api.volume)
this.original_volume = api.volume;
}
}
nextVideo() {
if (this.currentIndex === this.playlist.length - 1) {
// dont continue playing
@@ -374,7 +389,7 @@ export class PlayerComponent implements OnInit {
updatePlaylist() {
const fileNames = this.getFileNames();
this.playlist_updating = true;
this.postsService.updatePlaylist(this.id, fileNames, this.type).subscribe(res => {
this.postsService.updatePlaylistFiles(this.id, fileNames, this.type).subscribe(res => {
this.playlist_updating = false;
if (res['success']) {
const fileNamesEncoded = fileNames.join('|nvr|');

View File

@@ -274,8 +274,12 @@ export class PostsService implements CanActivate {
type: type, uuid: uuid}, this.httpOptions);
}
updatePlaylist(playlistID, fileNames, type) {
return this.http.post(this.path + 'updatePlaylist', {playlistID: playlistID,
updatePlaylist(playlist) {
return this.http.post(this.path + 'updatePlaylist', {playlist: playlist}, this.httpOptions);
}
updatePlaylistFiles(playlistID, fileNames, type) {
return this.http.post(this.path + 'updatePlaylistFiles', {playlistID: playlistID,
fileNames: fileNames,
type: type}, this.httpOptions);
}