1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/thememediaplayer.js

1 line
1.7 KiB
JavaScript
Raw Normal View History

2018-09-12 19:26:21 +02:00
define(["playbackManager","userSettings","connectionManager"],function(playbackManager,userSettings,connectionManager){"use strict";function playThemeMedia(items,ownerId){var currentThemeItems=items.filter(function(i){return enabled(i.MediaType)});if(currentThemeItems.length){if(!currentOwnerId&&playbackManager.isPlaying())return;currentThemeIds=currentThemeItems.map(function(i){return i.Id}),playbackManager.play({items:currentThemeItems,fullscreen:!1,enableRemotePlayers:!1}).then(function(){currentOwnerId=ownerId})}else stopIfPlaying()}function stopIfPlaying(){currentOwnerId&&playbackManager.stop(),currentOwnerId=null}function enabled(mediaType){return"Video"===mediaType?userSettings.enableThemeVideos():userSettings.enableThemeSongs()}function loadThemeMedia(item){if(item.CollectionType)return void stopIfPlaying();if(-1!==excludeTypes.indexOf(item.Type))return void stopIfPlaying();var apiClient=connectionManager.getApiClient(item.ServerId);apiClient.getThemeMedia(apiClient.getCurrentUserId(),item.Id,!0).then(function(themeMediaResult){var ownerId=themeMediaResult.ThemeVideosResult.Items.length?themeMediaResult.ThemeVideosResult.OwnerId:themeMediaResult.ThemeSongsResult.OwnerId;if(ownerId!==currentOwnerId){playThemeMedia(themeMediaResult.ThemeVideosResult.Items.length?themeMediaResult.ThemeVideosResult.Items:themeMediaResult.ThemeSongsResult.Items,ownerId)}})}var currentOwnerId,currentThemeIds=[],excludeTypes=["CollectionFolder","UserView","Program","SeriesTimer","Person","TvChannel","Channel"];document.addEventListener("viewshow",function(e){var state=e.detail.state||{},item=state.item;if(item&&item.ServerId)return void loadThemeMedia(item);(e.detail.options||{}).supportsThemeMedia||playThemeMedia([],null)},!0)});