mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update:Media item share URL allows for sending starting time as query string #1768
This commit is contained in:
parent
c309856f74
commit
d7ace4d1dc
@ -21,8 +21,12 @@ import LocalAudioPlayer from '../../players/LocalAudioPlayer'
|
||||
|
||||
export default {
|
||||
layout: 'blank',
|
||||
async asyncData({ params, error, app }) {
|
||||
const mediaItemShare = await app.$axios.$get(`/public/share/${params.slug}`).catch((error) => {
|
||||
async asyncData({ params, error, app, query }) {
|
||||
let endpoint = `/public/share/${params.slug}`
|
||||
if (query.t && !isNaN(query.t)) {
|
||||
endpoint += `?t=${query.t}`
|
||||
}
|
||||
const mediaItemShare = await app.$axios.$get(endpoint).catch((error) => {
|
||||
console.error('Failed', error)
|
||||
return null
|
||||
})
|
||||
|
@ -23,6 +23,8 @@ class ShareController {
|
||||
*/
|
||||
async getMediaItemShareBySlug(req, res) {
|
||||
const { slug } = req.params
|
||||
// Optional start time
|
||||
let startTime = req.query.t && !isNaN(req.query.t) ? Math.max(0, parseInt(req.query.t)) : 0
|
||||
|
||||
const mediaItemShare = ShareManager.findBySlug(slug)
|
||||
if (!mediaItemShare) {
|
||||
@ -68,8 +70,13 @@ class ShareController {
|
||||
return audioTrack
|
||||
})
|
||||
|
||||
if (startTime > startOffset) {
|
||||
Logger.warn(`[ShareController] Start time ${startTime} is greater than total duration ${startOffset}`)
|
||||
startTime = 0
|
||||
}
|
||||
|
||||
const newPlaybackSession = new PlaybackSession()
|
||||
newPlaybackSession.setData(oldLibraryItem, null, 'web-public', null, 0)
|
||||
newPlaybackSession.setData(oldLibraryItem, null, 'web-public', null, startTime)
|
||||
newPlaybackSession.audioTracks = publicTracks
|
||||
newPlaybackSession.playMethod = PlayMethod.DIRECTPLAY
|
||||
newPlaybackSession.shareSessionId = uuidv4() // New share session id
|
||||
|
Loading…
Reference in New Issue
Block a user