mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18: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) { | ||||
|     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) { | ||||
|  | ||||
| @ -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') | ||||
|  | ||||
| @ -29,5 +29,6 @@ module.exports.LogLevel = { | ||||
| module.exports.PlayMethod = { | ||||
|   DIRECTPLAY: 0, | ||||
|   DIRECTSTREAM: 1, | ||||
|   TRANSCODE: 2 | ||||
|   TRANSCODE: 2, | ||||
|   LOCAL: 3 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user