Update:Media item share endpoints and audio player #1768

- Add endpoints for getting tracks, getting cover image and updating progress
- Implement share session cookie and caching share playback session
- Audio player UI/UX
This commit is contained in:
advplyr 2024-06-29 15:05:35 -05:00
parent c1349e586a
commit 31146082f0
6 changed files with 229 additions and 33 deletions

View file

@ -12,12 +12,23 @@ class ShareManager {
constructor() {
/** @type {OpenMediaItemShareObject[]} */
this.openMediaItemShares = []
/** @type {import('../objects/PlaybackSession')[]} */
this.openSharePlaybackSessions = []
}
init() {
this.loadMediaItemShares()
}
/**
* @param {import('../objects/PlaybackSession')} playbackSession
*/
addOpenSharePlaybackSession(playbackSession) {
Logger.info(`[ShareManager] Adding new open share playback session ${playbackSession.shareSessionId}`)
this.openSharePlaybackSessions.push(playbackSession)
}
/**
* Find an open media item share by media item ID
* @param {string} mediaItemId
@ -52,6 +63,14 @@ class ShareManager {
return null
}
/**
* @param {string} shareSessionId
* @returns {import('../objects/PlaybackSession')}
*/
findPlaybackSessionBySessionId(shareSessionId) {
return this.openSharePlaybackSessions.find((s) => s.shareSessionId === shareSessionId)
}
/**
* Load all media item shares from the database
* Remove expired & schedule active
@ -123,6 +142,7 @@ class ShareManager {
}
this.openMediaItemShares = this.openMediaItemShares.filter((s) => s.id !== mediaItemShareId)
this.openSharePlaybackSessions = this.openSharePlaybackSessions.filter((s) => s.mediaItemShareId !== mediaItemShareId)
await this.destroyMediaItemShare(mediaItemShareId)
}