mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fixed logic and reduced overhead
This commit is contained in:
parent
8f8ebc485d
commit
6bea97ef0f
1 changed files with 15 additions and 27 deletions
|
@ -97,6 +97,15 @@ define(['playbackManager', 'nowPlayingHelper', 'events', 'connectionManager'], f
|
|||
}
|
||||
|
||||
function updatePlayerState(player, state, eventName) {
|
||||
var now = new Date().getTime();
|
||||
lastUpdateTime = now;
|
||||
|
||||
// Don't go crazy reporting position changes
|
||||
if (eventName == 'timeupdate' && (now - lastUpdateTime) < 5000) {
|
||||
// Only report if this item hasn't been reported yet, or if there's an actual playback change.
|
||||
// Don't report on simple time updates
|
||||
return;
|
||||
}
|
||||
|
||||
var item = state.NowPlayingItem;
|
||||
|
||||
|
@ -118,19 +127,9 @@ define(['playbackManager', 'nowPlayingHelper', 'events', 'connectionManager'], f
|
|||
}
|
||||
|
||||
var playState = state.PlayState || {};
|
||||
|
||||
var parts = nowPlayingHelper.getNowPlayingNames(item);
|
||||
|
||||
var artist = parts.length === 1 ? '' : parts[0].text;
|
||||
var title = parts[parts.length - 1].text;
|
||||
|
||||
// Switch these two around for video
|
||||
if (isVideo && parts.length > 1) {
|
||||
var temp = artist;
|
||||
artist = title;
|
||||
title = temp;
|
||||
}
|
||||
|
||||
var artist = parts[parts.length - 1].text;
|
||||
var title = parts.length === 1 ? '' : parts[0].text;
|
||||
var albumArtist;
|
||||
|
||||
if (item.AlbumArtists && item.AlbumArtists[0]) {
|
||||
|
@ -147,21 +146,10 @@ define(['playbackManager', 'nowPlayingHelper', 'events', 'connectionManager'], f
|
|||
var isPaused = playState.IsPaused || false;
|
||||
var canSeek = playState.CanSeek || false;
|
||||
|
||||
var now = new Date().getTime();
|
||||
|
||||
// Don't go crazy reporting position changes
|
||||
if (eventName == 'timeupdate' && (now - lastUpdateTime) < 5000) {
|
||||
// Only report if this item hasn't been reported yet, or if there's an actual playback change.
|
||||
// Don't report on simple time updates
|
||||
return;
|
||||
}
|
||||
|
||||
lastUpdateTime = now;
|
||||
|
||||
if (navigator.mediaSession) {
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: artist,
|
||||
artist: title,
|
||||
title: title,
|
||||
artist: artist,
|
||||
album: album,
|
||||
artwork: getImageUrls(item),
|
||||
albumArtist: albumArtist,
|
||||
|
@ -185,8 +173,8 @@ define(['playbackManager', 'nowPlayingHelper', 'events', 'connectionManager'], f
|
|||
action: eventName,
|
||||
isLocalPlayer: isLocalPlayer,
|
||||
itemId: itemId,
|
||||
title: artist,
|
||||
artist: title,
|
||||
title: title,
|
||||
artist: artist,
|
||||
album: album,
|
||||
duration: duration,
|
||||
position: currentTime,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue