From aba7108058f96e809f03365dd7d128cb7e5ebbfb Mon Sep 17 00:00:00 2001 From: kontiko Date: Sun, 30 Jun 2024 22:00:47 +0200 Subject: [PATCH] Fixed finish error and make continous playback working on android browsers --- client/players/DLNAPlayer.js | 20 ++++++++++++++------ client/players/PlayerHandler.js | 1 - server/objects/DLNASession.js | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/players/DLNAPlayer.js b/client/players/DLNAPlayer.js index 6c70deddf..247c67af0 100644 --- a/client/players/DLNAPlayer.js +++ b/client/players/DLNAPlayer.js @@ -18,17 +18,24 @@ export default class DLNAPlayer extends EventEmitter { this.paused this.currentTime = null //This is stupid but the best way to keep the site loaded on Smartphones is to have a fake player playing in the background \(^_^)/ + this.playableMimeTypes = ['audio/flac', 'audio/mpeg', 'audio/mp4', 'audio/ogg', 'audio/aac', 'audio/x-ms-wma', 'audio/x-aiff', 'audio/webm'] var audioEl = document.createElement('audio') audioEl.id = 'audio-player' audioEl.style.display = 'none' - audioEl.muted = true document.body.appendChild(audioEl) this.fake_player = audioEl - // TODO: Use canDisplayType on receiver to check mime types - this.playableMimeTypes = ['audio/flac', 'audio/mpeg', 'audio/mp4', 'audio/ogg', 'audio/aac', 'audio/x-ms-wma', 'audio/x-aiff', 'audio/webm'] - - this.coverUrl = '' - this.castPlayerState = 'IDLE' + this.fake_player.volume = 0.00001 + this.fake_player.addEventListener( + 'play', + function () { + setTimeout( + function () { + this.fake_player.muted = true + }.bind(this), + 1000 + ) + }.bind(this) + ) // Supported audio codecs for chromecast @@ -43,6 +50,7 @@ export default class DLNAPlayer extends EventEmitter { initialize() { this.ctx.$root.socket.on('dlna_status', (data) => this.setStatus(data)) + this.ctx.$root.socket.on('dlna_finished', () => this.emit('finished')) //this.player = this.ctx.$root.castPlayer } diff --git a/client/players/PlayerHandler.js b/client/players/PlayerHandler.js index fd7d138aa..30816428f 100644 --- a/client/players/PlayerHandler.js +++ b/client/players/PlayerHandler.js @@ -270,7 +270,6 @@ export default class PlayerHandler { if (session.playMethod === this.ctx.$constants.PlayMethod.DIRECTPLAY) { this.isHlsTranscode = false } - console.log('blub', audioTracks) this.player.set(this.libraryItem, audioTracks, this.isHlsTranscode, this.startTime, this.playWhenReady) } diff --git a/server/objects/DLNASession.js b/server/objects/DLNASession.js index 9187b0b41..225136f1f 100644 --- a/server/objects/DLNASession.js +++ b/server/objects/DLNASession.js @@ -29,7 +29,7 @@ class DLNASession { //If playback is stopped check if playback of track ended and Load new track var t = this.tracks[this.trackIndex] if (t.duration - this.playtime < 2) { - if (this.trackIndex < this.tracks.length) { + if (this.trackIndex < this.tracks.length - 1) { this.load(this.tracks[this.trackIndex + 1].startOffset) this.playtime = 0 return