From c201e2aa981fa64a32a90c0257b3ddb71d2ebf32 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 2 Apr 2022 11:19:57 -0500 Subject: [PATCH] Add mediaPlayer to playback session --- server/managers/PlaybackSessionManager.js | 3 ++- server/objects/PlaybackSession.js | 8 +++++++- server/utils/constants.js | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/managers/PlaybackSessionManager.js b/server/managers/PlaybackSessionManager.js index 20cb8c57..42524e64 100644 --- a/server/managers/PlaybackSessionManager.js +++ b/server/managers/PlaybackSessionManager.js @@ -44,12 +44,13 @@ class PlaybackSessionManager { async startSession(user, libraryItem, episodeId, options) { var shouldDirectPlay = options.forceDirectPlay || (!options.forceTranscode && libraryItem.media.checkCanDirectPlay(options, episodeId)) + var mediaPlayer = options.mediaPlayer || 'unknown' const userProgress = user.getMediaProgress(libraryItem.id, episodeId) var userStartTime = 0 if (userProgress) userStartTime = userProgress.currentTime || 0 const newPlaybackSession = new PlaybackSession() - newPlaybackSession.setData(libraryItem, user, episodeId) + newPlaybackSession.setData(libraryItem, user, mediaPlayer, episodeId) var audioTracks = [] if (shouldDirectPlay) { diff --git a/server/objects/PlaybackSession.js b/server/objects/PlaybackSession.js index 9d4365ce..ea510f37 100644 --- a/server/objects/PlaybackSession.js +++ b/server/objects/PlaybackSession.js @@ -19,6 +19,7 @@ class PlaybackSession { this.duration = null this.playMethod = null + this.mediaPlayer = null this.date = null this.dayOfWeek = null @@ -52,6 +53,7 @@ class PlaybackSession { coverPath: this.coverPath, duration: this.duration, playMethod: this.playMethod, + mediaPlayer: this.mediaPlayer, date: this.date, dayOfWeek: this.dayOfWeek, timeListening: this.timeListening, @@ -74,6 +76,7 @@ class PlaybackSession { coverPath: this.coverPath, duration: this.duration, playMethod: this.playMethod, + mediaPlayer: this.mediaPlayer, date: this.date, dayOfWeek: this.dayOfWeek, timeListening: this.timeListening, @@ -94,6 +97,7 @@ class PlaybackSession { this.mediaType = session.mediaType this.duration = session.duration this.playMethod = session.playMethod + this.mediaPlayer = session.mediaPlayer || null this.mediaMetadata = null if (session.mediaMetadata) { @@ -119,7 +123,7 @@ class PlaybackSession { 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.userId = user.id this.libraryItemId = libraryItem.id @@ -131,6 +135,8 @@ class PlaybackSession { this.coverPath = libraryItem.media.coverPath this.duration = libraryItem.media.duration + this.mediaPlayer = mediaPlayer + this.timeListening = 0 this.date = date.format(new Date(), 'YYYY-MM-DD') this.dayOfWeek = date.format(new Date(), 'dddd') diff --git a/server/utils/constants.js b/server/utils/constants.js index fc79b872..51f7adb5 100644 --- a/server/utils/constants.js +++ b/server/utils/constants.js @@ -29,5 +29,6 @@ module.exports.LogLevel = { module.exports.PlayMethod = { DIRECTPLAY: 0, DIRECTSTREAM: 1, - TRANSCODE: 2 + TRANSCODE: 2, + LOCAL: 3 } \ No newline at end of file