mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Move SyncPlay initialization to plugin
This commit is contained in:
parent
5b276b6e69
commit
d9bb55a2a9
4 changed files with 54 additions and 33 deletions
|
@ -16,7 +16,7 @@ class PlayerFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a wrapper to the list of players that can be managed.
|
* Registers a wrapper to the list of players that can be managed.
|
||||||
* @param {GenericPlayer} wrapperClass The wrapper to register.
|
* @param {typeof GenericPlayer} wrapperClass The wrapper to register.
|
||||||
*/
|
*/
|
||||||
registerWrapper(wrapperClass) {
|
registerWrapper(wrapperClass) {
|
||||||
console.debug('SyncPlay WrapperFactory registerWrapper:', wrapperClass.type);
|
console.debug('SyncPlay WrapperFactory registerWrapper:', wrapperClass.type);
|
||||||
|
@ -25,7 +25,7 @@ class PlayerFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default player wrapper.
|
* Sets the default player wrapper.
|
||||||
* @param {GenericPlayer} wrapperClass The wrapper.
|
* @param {typeof GenericPlayer} wrapperClass The wrapper.
|
||||||
*/
|
*/
|
||||||
setDefaultWrapper(wrapperClass) {
|
setDefaultWrapper(wrapperClass) {
|
||||||
console.debug('SyncPlay WrapperFactory setDefaultWrapper:', wrapperClass.type);
|
console.debug('SyncPlay WrapperFactory setDefaultWrapper:', wrapperClass.type);
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
"pdfPlayer/plugin",
|
"pdfPlayer/plugin",
|
||||||
"logoScreensaver/plugin",
|
"logoScreensaver/plugin",
|
||||||
"sessionPlayer/plugin",
|
"sessionPlayer/plugin",
|
||||||
"chromecastPlayer/plugin"
|
"chromecastPlayer/plugin",
|
||||||
|
"syncPlay/plugin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,6 @@ import './legacy/domParserTextHtml';
|
||||||
import './legacy/focusPreventScroll';
|
import './legacy/focusPreventScroll';
|
||||||
import './legacy/htmlMediaElement';
|
import './legacy/htmlMediaElement';
|
||||||
import './legacy/vendorStyles';
|
import './legacy/vendorStyles';
|
||||||
import SyncPlay from './components/syncPlay/core';
|
|
||||||
import { playbackManager } from './components/playback/playbackmanager';
|
|
||||||
import SyncPlayNoActivePlayer from './components/syncPlay/ui/players/NoActivePlayer';
|
|
||||||
import SyncPlayHtmlVideoPlayer from './components/syncPlay/ui/players/HtmlVideoPlayer';
|
|
||||||
import SyncPlayHtmlAudioPlayer from './components/syncPlay/ui/players/HtmlAudioPlayer';
|
|
||||||
import { currentSettings } from './scripts/settings/userSettings';
|
import { currentSettings } from './scripts/settings/userSettings';
|
||||||
import taskButton from './scripts/taskbutton';
|
import taskButton from './scripts/taskbutton';
|
||||||
import { HistoryRouter } from './components/HistoryRouter.tsx';
|
import { HistoryRouter } from './components/HistoryRouter.tsx';
|
||||||
|
@ -102,10 +97,7 @@ function onGlobalizeInit() {
|
||||||
|
|
||||||
import('./assets/css/librarybrowser.scss');
|
import('./assets/css/librarybrowser.scss');
|
||||||
|
|
||||||
loadPlugins().then(function () {
|
loadPlugins().then(onAppReady);
|
||||||
initSyncPlay();
|
|
||||||
onAppReady();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPlugins() {
|
function loadPlugins() {
|
||||||
|
@ -137,27 +129,6 @@ function loadPlugins() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSyncPlay() {
|
|
||||||
// Register player wrappers.
|
|
||||||
SyncPlay.PlayerFactory.setDefaultWrapper(SyncPlayNoActivePlayer);
|
|
||||||
SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlVideoPlayer);
|
|
||||||
SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlAudioPlayer);
|
|
||||||
|
|
||||||
// Listen for player changes.
|
|
||||||
Events.on(playbackManager, 'playerchange', (event, newPlayer, newTarget, oldPlayer) => {
|
|
||||||
SyncPlay.Manager.onPlayerChange(newPlayer, newTarget, oldPlayer);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Start SyncPlay.
|
|
||||||
const apiClient = ServerConnections.currentApiClient();
|
|
||||||
if (apiClient) SyncPlay.Manager.init(apiClient);
|
|
||||||
|
|
||||||
// FIXME: Multiple apiClients?
|
|
||||||
Events.on(ServerConnections, 'apiclientcreated', (e, newApiClient) => SyncPlay.Manager.init(newApiClient));
|
|
||||||
Events.on(ServerConnections, 'localusersignedin', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
|
||||||
Events.on(ServerConnections, 'localusersignedout', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onAppReady() {
|
async function onAppReady() {
|
||||||
console.debug('begin onAppReady');
|
console.debug('begin onAppReady');
|
||||||
|
|
||||||
|
|
49
src/plugins/syncPlay/plugin.ts
Normal file
49
src/plugins/syncPlay/plugin.ts
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import { Events } from 'jellyfin-apiclient';
|
||||||
|
|
||||||
|
import { playbackManager } from '../../components/playback/playbackmanager';
|
||||||
|
import ServerConnections from '../../components/ServerConnections';
|
||||||
|
import SyncPlay from '../../components/syncPlay/core';
|
||||||
|
import SyncPlayNoActivePlayer from '../../components/syncPlay/ui/players/NoActivePlayer';
|
||||||
|
import SyncPlayHtmlVideoPlayer from '../../components/syncPlay/ui/players/HtmlVideoPlayer';
|
||||||
|
import SyncPlayHtmlAudioPlayer from '../../components/syncPlay/ui/players/HtmlAudioPlayer';
|
||||||
|
|
||||||
|
class SyncPlayPlugin {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
priority: number;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.name = 'SyncPlay Plugin';
|
||||||
|
this.id = 'syncplay';
|
||||||
|
// NOTE: This should probably be a "mediaplayer" so the playback manager can handle playback logic, but
|
||||||
|
// SyncPlay needs refactored so it does not have an independent playback manager.
|
||||||
|
this.type = 'syncplay';
|
||||||
|
this.priority = 1;
|
||||||
|
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
// Register player wrappers.
|
||||||
|
SyncPlay.PlayerFactory.setDefaultWrapper(SyncPlayNoActivePlayer);
|
||||||
|
SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlVideoPlayer);
|
||||||
|
SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlAudioPlayer);
|
||||||
|
|
||||||
|
// Listen for player changes.
|
||||||
|
Events.on(playbackManager, 'playerchange', (_, newPlayer) => {
|
||||||
|
SyncPlay.Manager.onPlayerChange(newPlayer);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start SyncPlay.
|
||||||
|
const apiClient = ServerConnections.currentApiClient();
|
||||||
|
if (apiClient) SyncPlay.Manager.init(apiClient);
|
||||||
|
|
||||||
|
// FIXME: Multiple apiClients?
|
||||||
|
Events.on(ServerConnections, 'apiclientcreated', (_, newApiClient) => SyncPlay.Manager.init(newApiClient));
|
||||||
|
Events.on(ServerConnections, 'localusersignedin', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
||||||
|
Events.on(ServerConnections, 'localusersignedout', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SyncPlayPlugin;
|
Loading…
Add table
Add a link
Reference in a new issue