Update:Media item share URL allows for sending starting time as query string #1768

This commit is contained in:
advplyr 2024-06-30 15:31:27 -05:00
parent c309856f74
commit d7ace4d1dc
2 changed files with 14 additions and 3 deletions

View File

@ -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
})

View File

@ -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