Add mediaPlayer to playback session

This commit is contained in:
advplyr 2022-04-02 11:19:57 -05:00
parent 3d3f20296c
commit c201e2aa98
3 changed files with 11 additions and 3 deletions

View File

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

View File

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

View File

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