mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix media item share changing share, show error on failed to play
This commit is contained in:
		
							parent
							
								
									5858b64fc6
								
							
						
					
					
						commit
						dd1d2b7c92
					
				| @ -237,6 +237,13 @@ export default { | |||||||
|     resize() { |     resize() { | ||||||
|       this.windowWidth = window.innerWidth |       this.windowWidth = window.innerWidth | ||||||
|       this.windowHeight = window.innerHeight |       this.windowHeight = window.innerHeight | ||||||
|  |     }, | ||||||
|  |     playerError(error) { | ||||||
|  |       console.error('Player error', error) | ||||||
|  |       this.$toast.error('Failed to play audio on device') | ||||||
|  |     }, | ||||||
|  |     playerFinished() { | ||||||
|  |       console.log('Player finished') | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   mounted() { |   mounted() { | ||||||
| @ -252,12 +259,17 @@ export default { | |||||||
|     this.localAudioPlayer.set(null, this.audioTracks, false, startTime, false) |     this.localAudioPlayer.set(null, this.audioTracks, false, startTime, false) | ||||||
|     this.localAudioPlayer.on('stateChange', this.playerStateChange.bind(this)) |     this.localAudioPlayer.on('stateChange', this.playerStateChange.bind(this)) | ||||||
|     this.localAudioPlayer.on('timeupdate', this.playerTimeUpdate.bind(this)) |     this.localAudioPlayer.on('timeupdate', this.playerTimeUpdate.bind(this)) | ||||||
|  |     this.localAudioPlayer.on('error', this.playerError.bind(this)) | ||||||
|  |     this.localAudioPlayer.on('finished', this.playerFinished.bind(this)) | ||||||
|   }, |   }, | ||||||
|   beforeDestroy() { |   beforeDestroy() { | ||||||
|     window.removeEventListener('resize', this.resize) |     window.removeEventListener('resize', this.resize) | ||||||
|     window.removeEventListener('keydown', this.keyDown) |     window.removeEventListener('keydown', this.keyDown) | ||||||
| 
 | 
 | ||||||
|     this.localAudioPlayer.off('stateChange', this.playerStateChange) |     this.localAudioPlayer.off('stateChange', this.playerStateChange.bind(this)) | ||||||
|  |     this.localAudioPlayer.off('timeupdate', this.playerTimeUpdate.bind(this)) | ||||||
|  |     this.localAudioPlayer.off('error', this.playerError.bind(this)) | ||||||
|  |     this.localAudioPlayer.off('finished', this.playerFinished.bind(this)) | ||||||
|     this.localAudioPlayer.destroy() |     this.localAudioPlayer.destroy() | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -40,10 +40,22 @@ class ShareController { | |||||||
| 
 | 
 | ||||||
|     if (req.cookies.share_session_id) { |     if (req.cookies.share_session_id) { | ||||||
|       const playbackSession = ShareManager.findPlaybackSessionBySessionId(req.cookies.share_session_id) |       const playbackSession = ShareManager.findPlaybackSessionBySessionId(req.cookies.share_session_id) | ||||||
|  | 
 | ||||||
|       if (playbackSession) { |       if (playbackSession) { | ||||||
|  |         const playbackSessionMediaItemShare = ShareManager.findByMediaItemId(playbackSession.mediaItemId) | ||||||
|  |         if (!playbackSessionMediaItemShare) { | ||||||
|  |           Logger.error(`[ShareController] Share playback session ${req.cookies.share_session_id} media item share not found with id ${playbackSession.mediaItemId}`) | ||||||
|  |           return res.sendStatus(500) | ||||||
|  |         } | ||||||
|  |         if (playbackSessionMediaItemShare.slug === slug) { | ||||||
|           Logger.debug(`[ShareController] Found share playback session ${req.cookies.share_session_id}`) |           Logger.debug(`[ShareController] Found share playback session ${req.cookies.share_session_id}`) | ||||||
|           mediaItemShare.playbackSession = playbackSession.toJSONForClient() |           mediaItemShare.playbackSession = playbackSession.toJSONForClient() | ||||||
|           return res.json(mediaItemShare) |           return res.json(mediaItemShare) | ||||||
|  |         } else { | ||||||
|  |           // TODO: Close old session and use same session id
 | ||||||
|  |           Logger.info(`[ShareController] Share playback session found with id ${req.cookies.share_session_id} but media item share slug ${playbackSessionMediaItemShare.slug} does not match requested slug ${slug}`) | ||||||
|  |           res.clearCookie('share_session_id') | ||||||
|  |         } | ||||||
|       } else { |       } else { | ||||||
|         Logger.info(`[ShareController] Share playback session not found with id ${req.cookies.share_session_id}`) |         Logger.info(`[ShareController] Share playback session not found with id ${req.cookies.share_session_id}`) | ||||||
|         if (!uuid.validate(req.cookies.share_session_id) || uuid.version(req.cookies.share_session_id) !== 4) { |         if (!uuid.validate(req.cookies.share_session_id) || uuid.version(req.cookies.share_session_id) !== 4) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user