EmbyCrackedClient/web/videoosd/playqueue.js

1 line
4.5 KiB
JavaScript
Raw Normal View History

2025-06-25 11:46:04 +08:00
import playbackManager from"./../modules/common/playback/playbackmanager.js";import layoutManager from"./../modules/layoutmanager.js";import listView from"./../modules/listview/listview.js";import"./../modules/emby-elements/emby-scroller/emby-scroller.js";import"./../modules/emby-elements/emby-button/paper-icon-button-light.js";import"./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js";function buildDefaultLayout(parent,options){return parent.insertAdjacentHTML("afterbegin",'<div is="emby-scroller" class="osdPlayQueue flex flex-grow osdPlaylist-scroller osdPlaylist flex-direction-column hide osdContentSection osdContentSection-split osdPlayQueue-autosmall padded-left padded-right" data-contentsection="playqueue" data-mousewheel="true" data-horizontal="false" data-forcescrollbar="true" data-focusscroll="true"><div class="scrollSlider osdPlaylist-scrollSlider flex-grow flex-direction-column"><div is="emby-itemscontainer" class="flex-grow flex-direction-column vertical-list itemsContainer osdPlaylistItemsContainer" data-skipplaycommands="true" data-dragreorder="true" data-virtualscrolllayout="vertical-grid"></div></div></div>'),parent.querySelector(".osdPlayQueue")}function afterRefresh(){this.setScrollToTrack=!0,this.scrollToTrack&&(this.scrollToTrack=null,this.scrollCurrentTrackToTop())}function fetchPlaylistItems(query){var player=this.currentPlayer;return this.empty||!player?Promise.resolve({Items:[],TotalRecordCount:0}):playbackManager.getPlaylist(query||{},player)}function getPlaylistListOptions(items){return{renderer:listView,options:{smallIcon:!0,action:"setplaylistindex",playAction:"setplaylistindex",fields:["Name","ParentName"],enableUserDataButtons:!1,moreButton:!1,removeFromPlayQueueButton:!0,dragReorder:!layoutManager.tv,playQueueIndicator:!0,autoHideBorderOnTouch:!0,hideMoreButtonOnTouch:!0,autoMoveParentName:!0,buttonCommands:["removefromplayqueue"]},virtualScrollLayout:"vertical-list"}}function onPlaylistItemDrop(e){e.preventDefault();var newIndex=e.detail.newIndex,e=e.detail.items[0].PlaylistItemId;playbackManager.movePlaylistItem(e,newIndex,this.currentPlayer)}function OsdPlayQueue(options){(this.options=options).parent=buildDefaultLayout(options.parent,options);var parent=options.parent;this.playlistElement=options.parent,this.itemsContainer=parent.querySelector(".itemsContainer"),this.itemsContainer.fetchData=fetchPlaylistItems.bind(this),this.itemsContainer.afterRefresh=afterRefresh.bind(this),this.itemsContainer.getListOptions=getPlaylistListOptions.bind(this),this.itemsContainer.scrollResizeObserver=!0,this.itemsContainer.addEventListener("itemdrop",onPlaylistItemDrop.bind(this))}require(["css!videoosd/playqueue.css"]),OsdPlayQueue.prototype.scrollCurrentTrackToTop=function(){var itemsContainer,index=playbackManager.getCurrentPlaylistIndex(this.currentPlayer);-1!==index&&(itemsContainer=this.playlistElement.querySelector(".itemsContainer"))&&itemsContainer.scrollToIndex(index,{behavior:"instant",skipWhenVisibleY:!0},!1)},OsdPlayQueue.prototype.setPausedState=function(paused){var elem=this.playlistElement.querySelector(".playlistIndexIndicatorImage");elem&&(paused?elem.classList.add("playlistIndexIndicatorImage-paused"):elem.classList.remove("playlistIndexIndicatorImage-paused"))},OsdPlayQueue.prototype.updatePlaylist=function(player,playlistItemId,playlistIndex,playlistLength){this.currentPlayer=player,!1!==this.setScrollToTrack&&(this.scrollToTrack=!0),this.empty=!playlistLength,this.refreshItems()},OsdPlayQueue.prototype.onPlaybackStopped=function(){this.empty=!0,this.refreshItems()},OsdPlayQueue.prototype.refreshItems=function(){let itemsContainer=this.itemsContainer;if(itemsContainer)return itemsContainer.waitForCustomElementUpgrade().then(function(){itemsContainer.refreshItems()})},OsdPlayQueue.prototype.onPlaylistItemMoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.onPlaylistItemRemoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.pause=function(){this.paused=!0,this.itemsContainer.pause&&this.items