mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Add mediaPlayer to playback session
This commit is contained in:
parent
3d3f20296c
commit
c201e2aa98
@ -44,12 +44,13 @@ class PlaybackSessionManager {
|
|||||||
|
|
||||||
async startSession(user, libraryItem, episodeId, options) {
|
async startSession(user, libraryItem, episodeId, options) {
|
||||||
var shouldDirectPlay = options.forceDirectPlay || (!options.forceTranscode && libraryItem.media.checkCanDirectPlay(options, episodeId))
|
var shouldDirectPlay = options.forceDirectPlay || (!options.forceTranscode && libraryItem.media.checkCanDirectPlay(options, episodeId))
|
||||||
|
var mediaPlayer = options.mediaPlayer || 'unknown'
|
||||||
|
|
||||||
const userProgress = user.getMediaProgress(libraryItem.id, episodeId)
|
const userProgress = user.getMediaProgress(libraryItem.id, episodeId)
|
||||||
var userStartTime = 0
|
var userStartTime = 0
|
||||||
if (userProgress) userStartTime = userProgress.currentTime || 0
|
if (userProgress) userStartTime = userProgress.currentTime || 0
|
||||||
const newPlaybackSession = new PlaybackSession()
|
const newPlaybackSession = new PlaybackSession()
|
||||||
newPlaybackSession.setData(libraryItem, user, episodeId)
|
newPlaybackSession.setData(libraryItem, user, mediaPlayer, episodeId)
|
||||||
|
|
||||||
var audioTracks = []
|
var audioTracks = []
|
||||||
if (shouldDirectPlay) {
|
if (shouldDirectPlay) {
|
||||||
|
@ -19,6 +19,7 @@ class PlaybackSession {
|
|||||||
this.duration = null
|
this.duration = null
|
||||||
|
|
||||||
this.playMethod = null
|
this.playMethod = null
|
||||||
|
this.mediaPlayer = null
|
||||||
|
|
||||||
this.date = null
|
this.date = null
|
||||||
this.dayOfWeek = null
|
this.dayOfWeek = null
|
||||||
@ -52,6 +53,7 @@ class PlaybackSession {
|
|||||||
coverPath: this.coverPath,
|
coverPath: this.coverPath,
|
||||||
duration: this.duration,
|
duration: this.duration,
|
||||||
playMethod: this.playMethod,
|
playMethod: this.playMethod,
|
||||||
|
mediaPlayer: this.mediaPlayer,
|
||||||
date: this.date,
|
date: this.date,
|
||||||
dayOfWeek: this.dayOfWeek,
|
dayOfWeek: this.dayOfWeek,
|
||||||
timeListening: this.timeListening,
|
timeListening: this.timeListening,
|
||||||
@ -74,6 +76,7 @@ class PlaybackSession {
|
|||||||
coverPath: this.coverPath,
|
coverPath: this.coverPath,
|
||||||
duration: this.duration,
|
duration: this.duration,
|
||||||
playMethod: this.playMethod,
|
playMethod: this.playMethod,
|
||||||
|
mediaPlayer: this.mediaPlayer,
|
||||||
date: this.date,
|
date: this.date,
|
||||||
dayOfWeek: this.dayOfWeek,
|
dayOfWeek: this.dayOfWeek,
|
||||||
timeListening: this.timeListening,
|
timeListening: this.timeListening,
|
||||||
@ -94,6 +97,7 @@ class PlaybackSession {
|
|||||||
this.mediaType = session.mediaType
|
this.mediaType = session.mediaType
|
||||||
this.duration = session.duration
|
this.duration = session.duration
|
||||||
this.playMethod = session.playMethod
|
this.playMethod = session.playMethod
|
||||||
|
this.mediaPlayer = session.mediaPlayer || null
|
||||||
|
|
||||||
this.mediaMetadata = null
|
this.mediaMetadata = null
|
||||||
if (session.mediaMetadata) {
|
if (session.mediaMetadata) {
|
||||||
@ -119,7 +123,7 @@ class PlaybackSession {
|
|||||||
return Math.max(0, Math.min(this.currentTime / this.duration, 1))
|
return Math.max(0, Math.min(this.currentTime / this.duration, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(libraryItem, user, episodeId = null) {
|
setData(libraryItem, user, mediaPlayer, episodeId = null) {
|
||||||
this.id = getId('play')
|
this.id = getId('play')
|
||||||
this.userId = user.id
|
this.userId = user.id
|
||||||
this.libraryItemId = libraryItem.id
|
this.libraryItemId = libraryItem.id
|
||||||
@ -131,6 +135,8 @@ class PlaybackSession {
|
|||||||
this.coverPath = libraryItem.media.coverPath
|
this.coverPath = libraryItem.media.coverPath
|
||||||
this.duration = libraryItem.media.duration
|
this.duration = libraryItem.media.duration
|
||||||
|
|
||||||
|
this.mediaPlayer = mediaPlayer
|
||||||
|
|
||||||
this.timeListening = 0
|
this.timeListening = 0
|
||||||
this.date = date.format(new Date(), 'YYYY-MM-DD')
|
this.date = date.format(new Date(), 'YYYY-MM-DD')
|
||||||
this.dayOfWeek = date.format(new Date(), 'dddd')
|
this.dayOfWeek = date.format(new Date(), 'dddd')
|
||||||
|
@ -29,5 +29,6 @@ module.exports.LogLevel = {
|
|||||||
module.exports.PlayMethod = {
|
module.exports.PlayMethod = {
|
||||||
DIRECTPLAY: 0,
|
DIRECTPLAY: 0,
|
||||||
DIRECTSTREAM: 1,
|
DIRECTSTREAM: 1,
|
||||||
TRANSCODE: 2
|
TRANSCODE: 2,
|
||||||
|
LOCAL: 3
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user