jellyfin-web/dashboard-ui/components/remotecontrol.js

1 line
19 KiB
JavaScript
Raw Normal View History

define(["browser","datetime","backdrop","libraryBrowser","listView","imageLoader","playbackManager","nowPlayingHelper","events","connectionManager","apphost","globalize","cardStyle","emby-itemscontainer","css!css/nowplaying.css","emby-ratingbutton"],function(browser,datetime,backdrop,libraryBrowser,listView,imageLoader,playbackManager,nowPlayingHelper,events,connectionManager,appHost,globalize){"use strict";function showAudioMenu(context,player,button,item){var currentIndex=playbackManager.getAudioStreamIndex(player),streams=playbackManager.audioTracks(player),menuItems=streams.map(function(s){var menuItem={name:s.DisplayTitle,id:s.Index};return s.Index==currentIndex&&(menuItem.selected=!0),menuItem});require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:button,callback:function(id){playbackManager.setAudioStreamIndex(parseInt(id),player)}})})}function showSubtitleMenu(context,player,button,item){var currentIndex=playbackManager.getSubtitleStreamIndex(player),streams=playbackManager.subtitleTracks(player),menuItems=streams.map(function(s){var menuItem={name:s.DisplayTitle,id:s.Index};return s.Index==currentIndex&&(menuItem.selected=!0),menuItem});menuItems.unshift({id:-1,name:globalize.translate("ButtonOff"),selected:null==currentIndex}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:button,callback:function(id){playbackManager.setSubtitleStreamIndex(parseInt(id),player)}})})}function getNowPlayingNameHtml(nowPlayingItem,includeNonNameInfo){var names=nowPlayingHelper.getNowPlayingNames(nowPlayingItem,includeNonNameInfo);return names.map(function(i){return i.text}).join("<br/>")}function seriesImageUrl(item,options){if("Episode"!==item.Type)return null;if(options=options||{},options.type=options.type||"Primary","Primary"===options.type&&item.SeriesPrimaryImageTag)return options.tag=item.SeriesPrimaryImageTag,connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId,options);if("Thumb"===options.type){if(item.SeriesThumbImageTag)return options.tag=item.SeriesThumbImageTag,connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId,options);if(item.ParentThumbImageTag)return options.tag=item.ParentThumbImageTag,connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId,options)}return null}function imageUrl(item,options){return options=options||{},options.type=options.type||"Primary",item.ImageTags&&item.ImageTags[options.type]?(options.tag=item.ImageTags[options.type],connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId||item.Id,options)):item.AlbumId&&item.AlbumPrimaryImageTag?(options.tag=item.AlbumPrimaryImageTag,connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId,options)):null}function updateNowPlayingInfo(context,state){var item=state.NowPlayingItem,displayName=item?getNowPlayingNameHtml(item).replace("<br/>"," - "):"";context.querySelector(".nowPlayingPageTitle").innerHTML=displayName,displayName.length>0?context.querySelector(".nowPlayingPageTitle").classList.remove("hide"):context.querySelector(".nowPlayingPageTitle").classList.add("hide");var url=item?seriesImageUrl(item,{maxHeight:300})||imageUrl(item,{maxHeight:300}):null;if(url!==currentImgUrl)if(setImageUrl(context,url),item){backdrop.setBackdrops([item]);var apiClient=connectionManager.getApiClient(item.ServerId);apiClient.getItem(apiClient.getCurrentUserId(),item.Id).then(function(fullItem){var userData=fullItem.UserData||{},likes=null==userData.Likes?"":userData.Likes;context.querySelector(".nowPlayingPageUserDataButtons").innerHTML='<button is="emby-ratingbutton" type="button" class="listItemButton paper-icon-button-light" data-id="'+fullItem.Id+'" data-serverid="'+fullItem.ServerId+'" data-itemtype="'+fullItem.Type+'" data-likes="'+likes+'" data-isfavorite="'+userData.IsFavorite+'"><i class="md-icon">&#xE87D;</i></button>'})}else backdrop.clear(),context.querySelector(".nowPlayingPageUserDataButtons").innerHTML=""}function setImageUrl(context,url){cu