mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 17:59:06 +02:00
Update:Media item share URL allows for sending starting time as query string #1768
This commit is contained in:
parent
c309856f74
commit
d7ace4d1dc
2 changed files with 14 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue