mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-31 15:19:34 +02:00
Update:Scale chapter times with playback rate #726
This commit is contained in:
parent
b067a2d3d5
commit
c093548b71
3 changed files with 18 additions and 8 deletions
|
@ -95,7 +95,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<modals-chapters-modal v-model="showChapterModal" :current-chapter="currentChapter" :chapters="chapters" @select="selectChapter" />
|
<modals-chapters-modal v-model="showChapterModal" :current-chapter="currentChapter" :chapters="chapters" :playback-rate="currentPlaybackRate" @select="selectChapter" />
|
||||||
<modals-dialog v-model="showMoreMenuDialog" :items="menuItems" @action="clickMenuAction" />
|
<modals-dialog v-model="showMoreMenuDialog" :items="menuItems" @action="clickMenuAction" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
||||||
<div ref="container" class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
<div ref="container" class="w-full overflow-x-hidden overflow-y-auto bg-secondary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
||||||
<ul class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
<ul class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
||||||
<template v-for="(chapter, index) in chapters">
|
<template v-for="(chapter, index) in chapters">
|
||||||
<li :key="chapter.id" :id="`chapter-row-${chapter.id}`" class="text-gray-50 select-none relative py-4 cursor-pointer hover:bg-black-400" :class="currentChapterId === chapter.id ? 'bg-bg bg-opacity-80' : ''" role="option" @click="clickedOption(chapter)">
|
<li :key="chapter.id" :id="`chapter-row-${chapter.id}`" class="text-gray-50 select-none relative py-4 cursor-pointer" :class="currentChapterId === chapter.id ? 'bg-primary bg-opacity-80' : ''" role="option" @click="clickedOption(chapter)">
|
||||||
<div class="relative flex items-center pl-3 pr-20">
|
<div class="relative flex items-center pl-3 pr-20">
|
||||||
<p class="font-normal block truncate text-sm text-white text-opacity-80">{{ index + 1 }} - {{ chapter.title }}</p>
|
<p class="font-normal block truncate text-sm text-white text-opacity-80">{{ index + 1 }} - {{ chapter.title }}</p>
|
||||||
<div class="absolute top-0 right-3 -mt-0.5">
|
<div class="absolute top-0 right-3 -mt-0.5">
|
||||||
<span class="font-mono text-white text-opacity-90 leading-3 text-sm" style="letter-spacing: -0.5px">{{ $secondsToTimestamp(chapter.start) }}</span>
|
<span class="font-mono text-white text-opacity-90 leading-3 text-sm" style="letter-spacing: -0.5px">{{ $secondsToTimestamp(chapter.start / _playbackRate) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ export default {
|
||||||
currentChapter: {
|
currentChapter: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => null
|
default: () => null
|
||||||
}
|
},
|
||||||
|
playbackRate: Number
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {}
|
return {}
|
||||||
|
@ -57,11 +58,15 @@ export default {
|
||||||
this.$emit('input', val)
|
this.$emit('input', val)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
_playbackRate() {
|
||||||
|
if (!this.playbackRate || isNaN(this.playbackRate)) return 1
|
||||||
|
return this.playbackRate
|
||||||
|
},
|
||||||
currentChapterId() {
|
currentChapterId() {
|
||||||
return this.currentChapter ? this.currentChapter.id : null
|
return this.currentChapter?.id || null
|
||||||
},
|
},
|
||||||
currentChapterTitle() {
|
currentChapterTitle() {
|
||||||
return this.currentChapter ? this.currentChapter.title : null
|
return this.currentChapter?.title || null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -13,6 +13,7 @@ class AbsAudioPlayerWeb extends WebPlugin {
|
||||||
this.playWhenReady = false
|
this.playWhenReady = false
|
||||||
this.playableMimeTypes = {}
|
this.playableMimeTypes = {}
|
||||||
this.playbackSession = null
|
this.playbackSession = null
|
||||||
|
this.playbackRate = 1
|
||||||
this.audioTracks = []
|
this.audioTracks = []
|
||||||
this.startTime = 0
|
this.startTime = 0
|
||||||
this.trackStartTime = 0
|
this.trackStartTime = 0
|
||||||
|
@ -53,9 +54,11 @@ class AbsAudioPlayerWeb extends WebPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginMethod
|
// PluginMethod
|
||||||
async prepareLibraryItem({ libraryItemId, episodeId, playWhenReady, startTime }) {
|
async prepareLibraryItem({ libraryItemId, episodeId, playWhenReady, startTime, playbackRate }) {
|
||||||
console.log('[AbsAudioPlayer] Prepare library item', libraryItemId)
|
console.log('[AbsAudioPlayer] Prepare library item', libraryItemId)
|
||||||
|
|
||||||
|
if (!isNaN(playbackRate) && playbackRate) this.playbackRate = playbackRate
|
||||||
|
|
||||||
if (libraryItemId.startsWith('local_')) {
|
if (libraryItemId.startsWith('local_')) {
|
||||||
// Fetch Local - local not implemented on web
|
// Fetch Local - local not implemented on web
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,6 +137,7 @@ class AbsAudioPlayerWeb extends WebPlugin {
|
||||||
|
|
||||||
// PluginMethod
|
// PluginMethod
|
||||||
setPlaybackSpeed({ value }) {
|
setPlaybackSpeed({ value }) {
|
||||||
|
this.playbackRate = value
|
||||||
if (this.player) this.player.playbackRate = value
|
if (this.player) this.player.playbackRate = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +233,7 @@ class AbsAudioPlayerWeb extends WebPlugin {
|
||||||
this.player.src = `${vuexStore.getters['user/getServerAddress']}${this.currentTrack.contentUrl}?token=${vuexStore.getters['user/getToken']}`
|
this.player.src = `${vuexStore.getters['user/getServerAddress']}${this.currentTrack.contentUrl}?token=${vuexStore.getters['user/getToken']}`
|
||||||
console.log(`[AbsAudioPlayer] Loading track src ${this.player.src}`)
|
console.log(`[AbsAudioPlayer] Loading track src ${this.player.src}`)
|
||||||
this.player.load()
|
this.player.load()
|
||||||
|
this.player.playbackRate = this.playbackRate
|
||||||
}
|
}
|
||||||
|
|
||||||
setAudioPlayer(playbackSession, playWhenReady = false) {
|
setAudioPlayer(playbackSession, playWhenReady = false) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue