From 95bacce5e55244cf389dd1edc89c739a5f24228e Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 4 Mar 2022 18:44:20 -0600 Subject: [PATCH] Add:Start/complete date on audiobook page #383, Fix local hls stream url --- client/pages/audiobook/_id/index.vue | 19 ++++++++++++++----- client/players/AudioTrack.js | 10 ++++++++++ client/players/LocalPlayer.js | 4 ++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/client/pages/audiobook/_id/index.vue b/client/pages/audiobook/_id/index.vue index 3a14e6b9..de0a6dfb 100644 --- a/client/pages/audiobook/_id/index.vue +++ b/client/pages/audiobook/_id/index.vue @@ -47,7 +47,6 @@ {{ narrator }} -
@@ -95,9 +94,13 @@

Book has no audio tracks but has valid ebook files. The e-reader is experimental and can be turned on in config.

-
-

Your Progress: {{ Math.round(progressPercent * 100) }}%

-

{{ $elapsedPretty(userTimeRemaining) }} remaining

+ +
+

Your Progress: {{ Math.round(progressPercent * 100) }}%

+

Finished {{ $formatDate(userProgressFinishedAt, 'MM/dd/yyyy') }}

+

{{ $elapsedPretty(userTimeRemaining) }} remaining

+

Started {{ $formatDate(userProgressStartedAt, 'MM/dd/yyyy') }}

+
close
@@ -372,7 +375,13 @@ export default { return this.duration - this.userCurrentTime }, progressPercent() { - return this.userAudiobook ? this.userAudiobook.progress : 0 + return this.userAudiobook ? Math.max(Math.min(1, this.userAudiobook.progress), 0) : 0 + }, + userProgressStartedAt() { + return this.userAudiobook ? this.userAudiobook.startedAt : 0 + }, + userProgressFinishedAt() { + return this.userAudiobook ? this.userAudiobook.finishedAt : 0 }, streamAudiobook() { return this.$store.state.streamAudiobook diff --git a/client/players/AudioTrack.js b/client/players/AudioTrack.js index 5768092d..22aaf541 100644 --- a/client/players/AudioTrack.js +++ b/client/players/AudioTrack.js @@ -16,4 +16,14 @@ export default class AudioTrack { } return `${window.location.origin}${this.contentUrl}` } + + get relativeContentUrl() { + if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl + + if (process.env.NODE_ENV === 'development') { + return `${process.env.serverUrl}${this.contentUrl}` + } + + return this.contentUrl + } } \ No newline at end of file diff --git a/client/players/LocalPlayer.js b/client/players/LocalPlayer.js index 296f0940..5fbdad6d 100644 --- a/client/players/LocalPlayer.js +++ b/client/players/LocalPlayer.js @@ -99,7 +99,7 @@ export default class LocalPlayer extends EventEmitter { if (!Hls.isSupported()) { console.warn('HLS is not supported - fallback to using audio element') this.usingNativeplayer = true - this.player.src = this.currentTrack.contentUrl + this.player.src = this.currentTrack.relativeContentUrl this.player.currentTime = this.currentTime return } @@ -115,7 +115,7 @@ export default class LocalPlayer extends EventEmitter { this.hlsInstance.attachMedia(this.player) this.hlsInstance.on(Hls.Events.MEDIA_ATTACHED, () => { - this.hlsInstance.loadSource(this.currentTrack.contentUrl) + this.hlsInstance.loadSource(this.currentTrack.relativeContentUrl) this.hlsInstance.on(Hls.Events.MANIFEST_PARSED, () => { console.log('[HLS] Manifest Parsed')