mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration of sessionPlayer to ES6 module
This commit is contained in:
parent
e55c8958db
commit
e6ec5bab02
2 changed files with 263 additions and 284 deletions
|
@ -157,6 +157,7 @@
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
"src/plugins/experimentalWarnings/plugin.js",
|
"src/plugins/experimentalWarnings/plugin.js",
|
||||||
"src/plugins/htmlVideoPlayer/plugin.js",
|
"src/plugins/htmlVideoPlayer/plugin.js",
|
||||||
|
"src/plugins/sessionPlayer/plugin.js",
|
||||||
"src/components/search/searchfields.js",
|
"src/components/search/searchfields.js",
|
||||||
"src/components/search/searchresults.js",
|
"src/components/search/searchresults.js",
|
||||||
"src/components/settingshelper.js",
|
"src/components/settingshelper.js",
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
define(['playbackManager', 'events', 'serverNotifications', 'connectionManager'], function (playbackManager, events, serverNotifications, connectionManager) {
|
import playbackManager from 'playbackManager';
|
||||||
'use strict';
|
import events from 'events';
|
||||||
|
import serverNotifications from 'serverNotifications';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
|
||||||
playbackManager = playbackManager.default || playbackManager;
|
function getActivePlayerId() {
|
||||||
|
const info = playbackManager.getPlayerInfo();
|
||||||
function getActivePlayerId() {
|
|
||||||
var info = playbackManager.getPlayerInfo();
|
|
||||||
return info ? info.id : null;
|
return info ? info.id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendPlayCommand(apiClient, options, playType) {
|
function sendPlayCommand(apiClient, options, playType) {
|
||||||
var sessionId = getActivePlayerId();
|
const sessionId = getActivePlayerId();
|
||||||
|
|
||||||
var ids = options.ids || options.items.map(function (i) {
|
const ids = options.ids || options.items.map(function (i) {
|
||||||
return i.Id;
|
return i.Id;
|
||||||
});
|
});
|
||||||
|
|
||||||
var remoteOptions = {
|
const remoteOptions = {
|
||||||
ItemIds: ids.join(','),
|
ItemIds: ids.join(','),
|
||||||
|
|
||||||
PlayCommand: playType
|
PlayCommand: playType
|
||||||
|
@ -42,26 +42,26 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiClient.sendPlayCommand(sessionId, remoteOptions);
|
return apiClient.sendPlayCommand(sessionId, remoteOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendPlayStateCommand(apiClient, command, options) {
|
function sendPlayStateCommand(apiClient, command, options) {
|
||||||
var sessionId = getActivePlayerId();
|
const sessionId = getActivePlayerId();
|
||||||
|
|
||||||
apiClient.sendPlayStateCommand(sessionId, command, options);
|
apiClient.sendPlayStateCommand(sessionId, command, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentApiClient(instance) {
|
function getCurrentApiClient(instance) {
|
||||||
var currentServerId = instance.currentServerId;
|
const currentServerId = instance.currentServerId;
|
||||||
|
|
||||||
if (currentServerId) {
|
if (currentServerId) {
|
||||||
return connectionManager.getApiClient(currentServerId);
|
return connectionManager.getApiClient(currentServerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectionManager.currentApiClient();
|
return connectionManager.currentApiClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendCommandByName(instance, name, options) {
|
function sendCommandByName(instance, name, options) {
|
||||||
var command = {
|
const command = {
|
||||||
Name: name
|
Name: name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,21 +70,21 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.sendCommand(command);
|
instance.sendCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsubscribeFromPlayerUpdates(instance) {
|
function unsubscribeFromPlayerUpdates(instance) {
|
||||||
instance.isUpdating = true;
|
instance.isUpdating = true;
|
||||||
|
|
||||||
var apiClient = getCurrentApiClient(instance);
|
const apiClient = getCurrentApiClient(instance);
|
||||||
apiClient.sendMessage('SessionsStop');
|
apiClient.sendMessage('SessionsStop');
|
||||||
if (instance.pollInterval) {
|
if (instance.pollInterval) {
|
||||||
clearInterval(instance.pollInterval);
|
clearInterval(instance.pollInterval);
|
||||||
instance.pollInterval = null;
|
instance.pollInterval = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processUpdatedSessions(instance, sessions, apiClient) {
|
function processUpdatedSessions(instance, sessions, apiClient) {
|
||||||
var serverId = apiClient.serverId();
|
const serverId = apiClient.serverId();
|
||||||
|
|
||||||
sessions.map(function (s) {
|
sessions.map(function (s) {
|
||||||
if (s.NowPlayingItem) {
|
if (s.NowPlayingItem) {
|
||||||
|
@ -92,19 +92,19 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var currentTargetId = getActivePlayerId();
|
const currentTargetId = getActivePlayerId();
|
||||||
|
|
||||||
var session = sessions.filter(function (s) {
|
const session = sessions.filter(function (s) {
|
||||||
return s.Id === currentTargetId;
|
return s.Id === currentTargetId;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
normalizeImages(session, apiClient);
|
normalizeImages(session, apiClient);
|
||||||
|
|
||||||
var eventNames = getChangedEvents(instance.lastPlayerData, session);
|
const eventNames = getChangedEvents(instance.lastPlayerData, session);
|
||||||
instance.lastPlayerData = session;
|
instance.lastPlayerData = session;
|
||||||
|
|
||||||
for (var i = 0, length = eventNames.length; i < length; i++) {
|
for (let i = 0, length = eventNames.length; i < length; i++) {
|
||||||
events.trigger(instance, eventNames[i], [session]);
|
events.trigger(instance, eventNames[i], [session]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,10 +112,10 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
|
|
||||||
playbackManager.setDefaultPlayerActive();
|
playbackManager.setDefaultPlayerActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChangedEvents(state1, state2) {
|
function getChangedEvents(state1, state2) {
|
||||||
var names = [];
|
const names = [];
|
||||||
|
|
||||||
if (!state1) {
|
if (!state1) {
|
||||||
names.push('statechange');
|
names.push('statechange');
|
||||||
|
@ -131,33 +131,33 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
names.push('pause');
|
names.push('pause');
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPollIntervalFired() {
|
function onPollIntervalFired() {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
var apiClient = getCurrentApiClient(instance);
|
const apiClient = getCurrentApiClient(instance);
|
||||||
if (!apiClient.isMessageChannelOpen()) {
|
if (!apiClient.isMessageChannelOpen()) {
|
||||||
apiClient.getSessions().then(function (sessions) {
|
apiClient.getSessions().then(function (sessions) {
|
||||||
processUpdatedSessions(instance, sessions, apiClient);
|
processUpdatedSessions(instance, sessions, apiClient);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribeToPlayerUpdates(instance) {
|
function subscribeToPlayerUpdates(instance) {
|
||||||
instance.isUpdating = true;
|
instance.isUpdating = true;
|
||||||
|
|
||||||
var apiClient = getCurrentApiClient(instance);
|
const apiClient = getCurrentApiClient(instance);
|
||||||
apiClient.sendMessage('SessionsStart', '100,800');
|
apiClient.sendMessage('SessionsStart', '100,800');
|
||||||
if (instance.pollInterval) {
|
if (instance.pollInterval) {
|
||||||
clearInterval(instance.pollInterval);
|
clearInterval(instance.pollInterval);
|
||||||
instance.pollInterval = null;
|
instance.pollInterval = null;
|
||||||
}
|
}
|
||||||
instance.pollInterval = setInterval(onPollIntervalFired.bind(instance), 5000);
|
instance.pollInterval = setInterval(onPollIntervalFired.bind(instance), 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeImages(state, apiClient) {
|
function normalizeImages(state, apiClient) {
|
||||||
if (state && state.NowPlayingItem) {
|
if (state && state.NowPlayingItem) {
|
||||||
var item = state.NowPlayingItem;
|
const item = state.NowPlayingItem;
|
||||||
|
|
||||||
if (!item.ImageTags || !item.ImageTags.Primary) {
|
if (!item.ImageTags || !item.ImageTags.Primary) {
|
||||||
if (item.PrimaryImageTag) {
|
if (item.PrimaryImageTag) {
|
||||||
|
@ -176,10 +176,11 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
item.ServerId = apiClient.serverId();
|
item.ServerId = apiClient.serverId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function SessionPlayer() {
|
class SessionPlayer {
|
||||||
var self = this;
|
constructor() {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
this.name = 'Remote Control';
|
this.name = 'Remote Control';
|
||||||
this.type = 'mediaplayer';
|
this.type = 'mediaplayer';
|
||||||
|
@ -191,7 +192,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.beginPlayerUpdates = function () {
|
beginPlayerUpdates() {
|
||||||
this.playerListenerCount = this.playerListenerCount || 0;
|
this.playerListenerCount = this.playerListenerCount || 0;
|
||||||
|
|
||||||
if (this.playerListenerCount <= 0) {
|
if (this.playerListenerCount <= 0) {
|
||||||
|
@ -201,9 +202,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
}
|
}
|
||||||
|
|
||||||
this.playerListenerCount++;
|
this.playerListenerCount++;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.endPlayerUpdates = function () {
|
endPlayerUpdates() {
|
||||||
this.playerListenerCount = this.playerListenerCount || 0;
|
this.playerListenerCount = this.playerListenerCount || 0;
|
||||||
this.playerListenerCount--;
|
this.playerListenerCount--;
|
||||||
|
|
||||||
|
@ -211,21 +212,21 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
unsubscribeFromPlayerUpdates(this);
|
unsubscribeFromPlayerUpdates(this);
|
||||||
this.playerListenerCount = 0;
|
this.playerListenerCount = 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getPlayerState = function () {
|
getPlayerState() {
|
||||||
return this.lastPlayerData || {};
|
return this.lastPlayerData || {};
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getTargets = function () {
|
getTargets() {
|
||||||
var apiClient = getCurrentApiClient(this);
|
const apiClient = getCurrentApiClient(this);
|
||||||
|
|
||||||
var sessionQuery = {
|
const sessionQuery = {
|
||||||
ControllableByUserId: apiClient.getCurrentUserId()
|
ControllableByUserId: apiClient.getCurrentUserId()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (apiClient) {
|
if (apiClient) {
|
||||||
var name = this.name;
|
const name = this.name;
|
||||||
|
|
||||||
return apiClient.getSessions(sessionQuery).then(function (sessions) {
|
return apiClient.getSessions(sessionQuery).then(function (sessions) {
|
||||||
return sessions.filter(function (s) {
|
return sessions.filter(function (s) {
|
||||||
|
@ -242,11 +243,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
isLocalPlayer: false,
|
isLocalPlayer: false,
|
||||||
supportedCommands: s.Capabilities.SupportedCommands,
|
supportedCommands: s.Capabilities.SupportedCommands,
|
||||||
user: s.UserId ? {
|
user: s.UserId ? {
|
||||||
|
|
||||||
Id: s.UserId,
|
Id: s.UserId,
|
||||||
Name: s.UserName,
|
Name: s.UserName,
|
||||||
PrimaryImageTag: s.UserPrimaryImageTag
|
PrimaryImageTag: s.UserPrimaryImageTag
|
||||||
|
|
||||||
} : null
|
} : null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -254,16 +253,16 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.sendCommand = function (command) {
|
sendCommand(command) {
|
||||||
var sessionId = getActivePlayerId();
|
const sessionId = getActivePlayerId();
|
||||||
|
|
||||||
var apiClient = getCurrentApiClient(this);
|
const apiClient = getCurrentApiClient(this);
|
||||||
apiClient.sendCommand(sessionId, command);
|
apiClient.sendCommand(sessionId, command);
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.play = function (options) {
|
play(options) {
|
||||||
options = Object.assign({}, options);
|
options = Object.assign({}, options);
|
||||||
|
|
||||||
if (options.items) {
|
if (options.items) {
|
||||||
|
@ -275,251 +274,230 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendPlayCommand(getCurrentApiClient(this), options, 'PlayNow');
|
return sendPlayCommand(getCurrentApiClient(this), options, 'PlayNow');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.shuffle = function (item) {
|
shuffle(item) {
|
||||||
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle');
|
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.instantMix = function (item) {
|
instantMix(item) {
|
||||||
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix');
|
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.queue = function (options) {
|
queue(options) {
|
||||||
sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext');
|
sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.queueNext = function (options) {
|
queueNext(options) {
|
||||||
sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast');
|
sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.canPlayMediaType = function (mediaType) {
|
canPlayMediaType(mediaType) {
|
||||||
mediaType = (mediaType || '').toLowerCase();
|
mediaType = (mediaType || '').toLowerCase();
|
||||||
return mediaType === 'audio' || mediaType === 'video';
|
return mediaType === 'audio' || mediaType === 'video';
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.canQueueMediaType = function (mediaType) {
|
canQueueMediaType(mediaType) {
|
||||||
return this.canPlayMediaType(mediaType);
|
return this.canPlayMediaType(mediaType);
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.stop = function () {
|
stop() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'stop');
|
sendPlayStateCommand(getCurrentApiClient(this), 'stop');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.nextTrack = function () {
|
nextTrack() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'nextTrack');
|
sendPlayStateCommand(getCurrentApiClient(this), 'nextTrack');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.previousTrack = function () {
|
previousTrack() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'previousTrack');
|
sendPlayStateCommand(getCurrentApiClient(this), 'previousTrack');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.seek = function (positionTicks) {
|
seek(positionTicks) {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'seek',
|
sendPlayStateCommand(getCurrentApiClient(this), 'seek',
|
||||||
{
|
{
|
||||||
SeekPositionTicks: positionTicks
|
SeekPositionTicks: positionTicks
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.currentTime = function (val) {
|
currentTime(val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
return this.seek(val);
|
return this.seek(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.PositionTicks;
|
return state.PositionTicks;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.duration = function () {
|
duration() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.NowPlayingItem || {};
|
state = state.NowPlayingItem || {};
|
||||||
return state.RunTimeTicks;
|
return state.RunTimeTicks;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.paused = function () {
|
paused() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.IsPaused;
|
return state.IsPaused;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getVolume = function () {
|
getVolume() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.VolumeLevel;
|
return state.VolumeLevel;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.isMuted = function () {
|
isMuted() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.IsMuted;
|
return state.IsMuted;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.pause = function () {
|
pause() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'Pause');
|
sendPlayStateCommand(getCurrentApiClient(this), 'Pause');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.unpause = function () {
|
unpause() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'Unpause');
|
sendPlayStateCommand(getCurrentApiClient(this), 'Unpause');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.playPause = function () {
|
playPause() {
|
||||||
sendPlayStateCommand(getCurrentApiClient(this), 'PlayPause');
|
sendPlayStateCommand(getCurrentApiClient(this), 'PlayPause');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.setMute = function (isMuted) {
|
setMute(isMuted) {
|
||||||
if (isMuted) {
|
if (isMuted) {
|
||||||
sendCommandByName(this, 'Mute');
|
sendCommandByName(this, 'Mute');
|
||||||
} else {
|
} else {
|
||||||
sendCommandByName(this, 'Unmute');
|
sendCommandByName(this, 'Unmute');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.toggleMute = function () {
|
toggleMute() {
|
||||||
sendCommandByName(this, 'ToggleMute');
|
sendCommandByName(this, 'ToggleMute');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.setVolume = function (vol) {
|
setVolume(vol) {
|
||||||
sendCommandByName(this, 'SetVolume', {
|
sendCommandByName(this, 'SetVolume', {
|
||||||
Volume: vol
|
Volume: vol
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.volumeUp = function () {
|
volumeUp() {
|
||||||
sendCommandByName(this, 'VolumeUp');
|
sendCommandByName(this, 'VolumeUp');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.volumeDown = function () {
|
volumeDown() {
|
||||||
sendCommandByName(this, 'VolumeDown');
|
sendCommandByName(this, 'VolumeDown');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.toggleFullscreen = function () {
|
toggleFullscreen() {
|
||||||
sendCommandByName(this, 'ToggleFullscreen');
|
sendCommandByName(this, 'ToggleFullscreen');
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.audioTracks = function () {
|
audioTracks() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.NowPlayingItem || {};
|
state = state.NowPlayingItem || {};
|
||||||
var streams = state.MediaStreams || [];
|
const streams = state.MediaStreams || [];
|
||||||
return streams.filter(function (s) {
|
return streams.filter(function (s) {
|
||||||
return s.Type === 'Audio';
|
return s.Type === 'Audio';
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getAudioStreamIndex = function () {
|
getAudioStreamIndex() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.AudioStreamIndex;
|
return state.AudioStreamIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.playTrailers = function (item) {
|
playTrailers(item) {
|
||||||
sendCommandByName(this, 'PlayTrailers', {
|
sendCommandByName(this, 'PlayTrailers', {
|
||||||
ItemId: item.Id
|
ItemId: item.Id
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.setAudioStreamIndex = function (index) {
|
setAudioStreamIndex(index) {
|
||||||
sendCommandByName(this, 'SetAudioStreamIndex', {
|
sendCommandByName(this, 'SetAudioStreamIndex', {
|
||||||
Index: index
|
Index: index
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.subtitleTracks = function () {
|
subtitleTracks() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.NowPlayingItem || {};
|
state = state.NowPlayingItem || {};
|
||||||
var streams = state.MediaStreams || [];
|
const streams = state.MediaStreams || [];
|
||||||
return streams.filter(function (s) {
|
return streams.filter(function (s) {
|
||||||
return s.Type === 'Subtitle';
|
return s.Type === 'Subtitle';
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getSubtitleStreamIndex = function () {
|
getSubtitleStreamIndex() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.PlayState || {};
|
state = state.PlayState || {};
|
||||||
return state.SubtitleStreamIndex;
|
return state.SubtitleStreamIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.setSubtitleStreamIndex = function (index) {
|
setSubtitleStreamIndex(index) {
|
||||||
sendCommandByName(this, 'SetSubtitleStreamIndex', {
|
sendCommandByName(this, 'SetSubtitleStreamIndex', {
|
||||||
Index: index
|
Index: index
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getMaxStreamingBitrate = function () {
|
setMaxStreamingBitrate(options) {
|
||||||
|
}
|
||||||
|
|
||||||
};
|
setRepeatMode(mode) {
|
||||||
|
|
||||||
SessionPlayer.prototype.setMaxStreamingBitrate = function (options) {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionPlayer.prototype.isFullscreen = function () {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionPlayer.prototype.toggleFullscreen = function () {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionPlayer.prototype.getRepeatMode = function () {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionPlayer.prototype.setRepeatMode = function (mode) {
|
|
||||||
sendCommandByName(this, 'SetRepeatMode', {
|
sendCommandByName(this, 'SetRepeatMode', {
|
||||||
RepeatMode: mode
|
RepeatMode: mode
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.setQueueShuffleMode = function (mode) {
|
setQueueShuffleMode(mode) {
|
||||||
sendCommandByName(this, 'SetShuffleQueue', {
|
sendCommandByName(this, 'SetShuffleQueue', {
|
||||||
ShuffleMode: mode
|
ShuffleMode: mode
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getQueueShuffleMode = function () {
|
getQueueShuffleMode() {
|
||||||
|
}
|
||||||
|
|
||||||
};
|
displayContent(options) {
|
||||||
|
|
||||||
SessionPlayer.prototype.displayContent = function (options) {
|
|
||||||
sendCommandByName(this, 'DisplayContent', options);
|
sendCommandByName(this, 'DisplayContent', options);
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.isPlaying = function () {
|
isPlaying() {
|
||||||
var state = this.lastPlayerData || {};
|
const state = this.lastPlayerData || {};
|
||||||
return state.NowPlayingItem != null;
|
return state.NowPlayingItem != null;
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.isPlayingVideo = function () {
|
isPlayingVideo() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.NowPlayingItem || {};
|
state = state.NowPlayingItem || {};
|
||||||
return state.MediaType === 'Video';
|
return state.MediaType === 'Video';
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.isPlayingAudio = function () {
|
isPlayingAudio() {
|
||||||
var state = this.lastPlayerData || {};
|
let state = this.lastPlayerData || {};
|
||||||
state = state.NowPlayingItem || {};
|
state = state.NowPlayingItem || {};
|
||||||
return state.MediaType === 'Audio';
|
return state.MediaType === 'Audio';
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getPlaylist = function () {
|
getPlaylist() {
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.getCurrentPlaylistItemId = function () {
|
setCurrentPlaylistItem(playlistItemId) {
|
||||||
};
|
|
||||||
|
|
||||||
SessionPlayer.prototype.setCurrentPlaylistItem = function (playlistItemId) {
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.removeFromPlaylist = function (playlistItemIds) {
|
removeFromPlaylist(playlistItemIds) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionPlayer.prototype.tryPair = function (target) {
|
tryPair(target) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SessionPlayer;
|
export default SessionPlayer;
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue