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