mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add plugin types
This commit is contained in:
parent
ecb84ff351
commit
64ecc3eae7
18 changed files with 51 additions and 20 deletions
|
@ -8,6 +8,7 @@ import datetime from '../../scripts/datetime';
|
|||
import globalize from '../../scripts/globalize';
|
||||
import loading from '../loading/loading';
|
||||
import skinManager from '../../scripts/themeManager';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
import '../../elements/emby-select/emby-select';
|
||||
import '../../elements/emby-checkbox/emby-checkbox';
|
||||
|
@ -35,7 +36,7 @@ import template from './displaySettings.template.html';
|
|||
|
||||
function loadScreensavers(context, userSettings) {
|
||||
const selectScreensaver = context.querySelector('.selectScreensaver');
|
||||
const options = pluginManager.ofType('screensaver').map(plugin => {
|
||||
const options = pluginManager.ofType(PluginType.Screensaver).map(plugin => {
|
||||
return {
|
||||
name: plugin.name,
|
||||
value: plugin.id
|
||||
|
|
|
@ -11,6 +11,7 @@ import { appHost } from '../apphost';
|
|||
import Screenfull from 'screenfull';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
import alert from '../alert';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import { includesAny } from '../../utils/container.ts';
|
||||
|
||||
const UNLIMITED_ITEMS = -1;
|
||||
|
@ -2268,7 +2269,7 @@ class PlaybackManager {
|
|||
|
||||
function runInterceptors(item, playOptions) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const interceptors = pluginManager.ofType('preplayintercept');
|
||||
const interceptors = pluginManager.ofType(PluginType.PreplayIntercept);
|
||||
|
||||
interceptors.sort(function (a, b) {
|
||||
return (a.order || 0) - (b.order || 0);
|
||||
|
@ -3387,12 +3388,12 @@ class PlaybackManager {
|
|||
}
|
||||
|
||||
Events.on(pluginManager, 'registered', function (e, plugin) {
|
||||
if (plugin.type === 'mediaplayer') {
|
||||
if (plugin.type === PluginType.MediaPlayer) {
|
||||
initMediaPlayer(plugin);
|
||||
}
|
||||
});
|
||||
|
||||
pluginManager.ofType('mediaplayer').forEach(initMediaPlayer);
|
||||
pluginManager.ofType(PluginType.MediaPlayer).forEach(initMediaPlayer);
|
||||
|
||||
function sendProgressUpdate(player, progressEventName, reportPlaylist) {
|
||||
if (!player) {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
/* eslint-disable indent */
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
class BackdropScreensaver {
|
||||
constructor() {
|
||||
this.name = 'Backdrop ScreenSaver';
|
||||
this.type = 'screensaver';
|
||||
this.type = PluginType.Screensaver;
|
||||
this.id = 'backdropscreensaver';
|
||||
this.supportsAnonymous = false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import TableOfContents from './tableOfContents';
|
|||
import dom from '../../scripts/dom';
|
||||
import { translateHtml } from '../../scripts/globalize';
|
||||
import * as userSettings from '../../scripts/settings/userSettings';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
import '../../elements/emby-button/paper-icon-button-light';
|
||||
|
@ -19,7 +20,7 @@ import './style.scss';
|
|||
export class BookPlayer {
|
||||
constructor() {
|
||||
this.name = 'Book Player';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'bookplayer';
|
||||
this.priority = 1;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import globalize from '../../scripts/globalize';
|
|||
import castSenderApiLoader from './castSenderApi';
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
import alert from '../../components/alert';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
// Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
|
||||
|
@ -569,7 +570,7 @@ class ChromecastPlayer {
|
|||
constructor() {
|
||||
// playbackManager needs this
|
||||
this.name = PlayerName;
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'chromecast';
|
||||
this.isLocalPlayer = false;
|
||||
this.lastPlayerData = {};
|
||||
|
|
|
@ -6,13 +6,14 @@ import keyboardnavigation from '../../scripts/keyboardNavigation';
|
|||
import { appRouter } from '../../components/appRouter';
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
import * as userSettings from '../../scripts/settings/userSettings';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
import './style.scss';
|
||||
|
||||
export class ComicsPlayer {
|
||||
constructor() {
|
||||
this.name = 'Comics Player';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'comicsplayer';
|
||||
this.priority = 1;
|
||||
this.imageMap = new Map();
|
||||
|
|
|
@ -2,6 +2,7 @@ import globalize from '../../scripts/globalize';
|
|||
import * as userSettings from '../../scripts/settings/userSettings';
|
||||
import { appHost } from '../../components/apphost';
|
||||
import alert from '../../components/alert';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
// TODO: Replace with date-fns
|
||||
// https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php
|
||||
|
@ -46,7 +47,7 @@ function showIsoMessage() {
|
|||
class ExpirementalPlaybackWarnings {
|
||||
constructor() {
|
||||
this.name = 'Experimental playback warnings';
|
||||
this.type = 'preplayintercept';
|
||||
this.type = PluginType.PreplayIntercept;
|
||||
this.id = 'expirementalplaybackwarnings';
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { appHost } from '../../components/apphost';
|
|||
import * as htmlMediaHelper from '../../components/htmlMediaHelper';
|
||||
import profileBuilder from '../../scripts/browserDeviceProfile';
|
||||
import { getIncludeCorsCredentials } from '../../scripts/settings/webSettings';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
function getDefaultProfile() {
|
||||
|
@ -85,7 +86,7 @@ class HtmlAudioPlayer {
|
|||
const self = this;
|
||||
|
||||
self.name = 'Html Audio Player';
|
||||
self.type = 'mediaplayer';
|
||||
self.type = PluginType.MediaPlayer;
|
||||
self.id = 'htmlaudioplayer';
|
||||
|
||||
// Let any players created by plugins take priority
|
||||
|
|
|
@ -30,6 +30,7 @@ import ServerConnections from '../../components/ServerConnections';
|
|||
import profileBuilder, { canPlaySecondaryAudio } from '../../scripts/browserDeviceProfile';
|
||||
import { getIncludeCorsCredentials } from '../../scripts/settings/webSettings';
|
||||
import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../components/backdrop/backdrop';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
import { includesAny } from '../../utils/container.ts';
|
||||
|
||||
|
@ -166,7 +167,7 @@ function tryRemoveElement(elem) {
|
|||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
type = 'mediaplayer';
|
||||
type = PluginType.MediaPlayer;
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
export default function () {
|
||||
const self = this;
|
||||
|
||||
self.name = 'Logo ScreenSaver';
|
||||
self.type = 'screensaver';
|
||||
self.type = PluginType.Screensaver;
|
||||
self.id = 'logoscreensaver';
|
||||
self.supportsAnonymous = true;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import keyboardnavigation from '../../scripts/keyboardNavigation';
|
|||
import dialogHelper from '../../components/dialogHelper/dialogHelper';
|
||||
import dom from '../../scripts/dom';
|
||||
import { appRouter } from '../../components/appRouter';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
import './style.scss';
|
||||
|
@ -12,7 +13,7 @@ import '../../elements/emby-button/paper-icon-button-light';
|
|||
export class PdfPlayer {
|
||||
constructor() {
|
||||
this.name = 'PDF Player';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'pdfplayer';
|
||||
this.priority = 1;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import ServerConnections from '../../components/ServerConnections';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
export default class PhotoPlayer {
|
||||
constructor() {
|
||||
this.name = 'Photo Player';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'photoplayer';
|
||||
this.priority = 1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import globalize from '../../scripts/globalize';
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
import alert from '../../components/alert';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
|
||||
function showErrorMessage() {
|
||||
return alert(globalize.translate('MessagePlayAccessRestricted'));
|
||||
|
@ -9,7 +10,7 @@ function showErrorMessage() {
|
|||
class PlayAccessValidation {
|
||||
constructor() {
|
||||
this.name = 'Playback validation';
|
||||
this.type = 'preplayintercept';
|
||||
this.type = PluginType.PreplayIntercept;
|
||||
this.id = 'playaccessvalidation';
|
||||
this.order = -2;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { playbackManager } from '../../components/playback/playbackmanager';
|
||||
import serverNotifications from '../../scripts/serverNotifications';
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
function getActivePlayerId() {
|
||||
|
@ -181,7 +182,7 @@ class SessionPlayer {
|
|||
const self = this;
|
||||
|
||||
this.name = 'Remote Control';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.isLocalPlayer = false;
|
||||
this.id = 'remoteplayer';
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import SyncPlay from './core';
|
|||
import SyncPlayNoActivePlayer from './ui/players/NoActivePlayer';
|
||||
import SyncPlayHtmlVideoPlayer from './ui/players/HtmlVideoPlayer';
|
||||
import SyncPlayHtmlAudioPlayer from './ui/players/HtmlAudioPlayer';
|
||||
import { Plugin, PluginType } from '../../types/plugin';
|
||||
|
||||
class SyncPlayPlugin {
|
||||
class SyncPlayPlugin implements Plugin {
|
||||
name: string;
|
||||
id: string;
|
||||
type: string;
|
||||
|
@ -17,7 +18,7 @@ class SyncPlayPlugin {
|
|||
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.type = PluginType.SyncPlay;
|
||||
this.priority = 1;
|
||||
|
||||
this.init();
|
||||
|
|
|
@ -2,6 +2,7 @@ import browser from '../../scripts/browser';
|
|||
import { appRouter } from '../../components/appRouter';
|
||||
import loading from '../../components/loading/loading';
|
||||
import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../components/backdrop/backdrop';
|
||||
import { PluginType } from '../../types/plugin.ts';
|
||||
import Events from '../../utils/events.ts';
|
||||
|
||||
/* globals YT */
|
||||
|
@ -197,7 +198,7 @@ function setCurrentSrc(instance, elem, options) {
|
|||
class YoutubePlayer {
|
||||
constructor() {
|
||||
this.name = 'Youtube Player';
|
||||
this.type = 'mediaplayer';
|
||||
this.type = PluginType.MediaPlayer;
|
||||
this.id = 'youtubeplayer';
|
||||
|
||||
// Let any players created by plugins take priority
|
||||
|
|
|
@ -3,6 +3,7 @@ import { pluginManager } from '../components/pluginManager';
|
|||
import inputManager from './inputManager';
|
||||
import * as userSettings from './settings/userSettings';
|
||||
import ServerConnections from '../components/ServerConnections';
|
||||
import { PluginType } from '../types/plugin.ts';
|
||||
import Events from '../utils/events.ts';
|
||||
|
||||
import './screensavermanager.scss';
|
||||
|
@ -34,7 +35,7 @@ function getScreensaverPlugin(isLoggedIn) {
|
|||
option = isLoggedIn ? 'backdropscreensaver' : 'logoscreensaver';
|
||||
}
|
||||
|
||||
const plugins = pluginManager.ofType('screensaver');
|
||||
const plugins = pluginManager.ofType(PluginType.Screensaver);
|
||||
|
||||
for (const plugin of plugins) {
|
||||
if (plugin.id === option) {
|
||||
|
|
13
src/types/plugin.ts
Normal file
13
src/types/plugin.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
export enum PluginType {
|
||||
MediaPlayer = 'mediaplayer',
|
||||
PreplayIntercept = 'preplayintercept',
|
||||
Screensaver = 'screensaver',
|
||||
SyncPlay = 'syncplay'
|
||||
}
|
||||
|
||||
export interface Plugin {
|
||||
name: string
|
||||
id: string
|
||||
type: PluginType | string
|
||||
priority: number
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue