2019-01-23 11:33:34 +00:00
|
|
|
define(['playbackManager', 'events', 'serverNotifications', 'connectionManager'], function (playbackManager, events, serverNotifications, connectionManager) {
|
2019-01-10 15:39:37 +03:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function getActivePlayerId() {
|
|
|
|
var info = playbackManager.getPlayerInfo();
|
2019-01-10 15:39:37 +03:00
|
|
|
return info ? info.id : null;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendPlayCommand(apiClient, options, playType) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var sessionId = getActivePlayerId();
|
|
|
|
|
|
|
|
var ids = options.ids || options.items.map(function (i) {
|
|
|
|
return i.Id;
|
|
|
|
});
|
|
|
|
|
|
|
|
var remoteOptions = {
|
|
|
|
ItemIds: ids.join(','),
|
|
|
|
|
|
|
|
PlayCommand: playType
|
|
|
|
};
|
|
|
|
|
|
|
|
if (options.startPositionTicks) {
|
|
|
|
remoteOptions.StartPositionTicks = options.startPositionTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.mediaSourceId) {
|
|
|
|
remoteOptions.MediaSourceId = options.mediaSourceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.audioStreamIndex != null) {
|
|
|
|
remoteOptions.AudioStreamIndex = options.audioStreamIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.subtitleStreamIndex != null) {
|
|
|
|
remoteOptions.SubtitleStreamIndex = options.subtitleStreamIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.startIndex != null) {
|
|
|
|
remoteOptions.StartIndex = options.startIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiClient.sendPlayCommand(sessionId, remoteOptions);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendPlayStateCommand(apiClient, command, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var sessionId = getActivePlayerId();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
apiClient.sendPlayStateCommand(sessionId, command, options);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCurrentApiClient(instance) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var currentServerId = instance.currentServerId;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (currentServerId) {
|
|
|
|
return connectionManager.getApiClient(currentServerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return connectionManager.currentApiClient();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function sendCommandByName(instance, name, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var command = {
|
|
|
|
Name: name
|
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (options) {
|
|
|
|
command.Arguments = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance.sendCommand(command);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function unsubscribeFromPlayerUpdates(instance) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
instance.isUpdating = true;
|
|
|
|
|
|
|
|
var apiClient = getCurrentApiClient(instance);
|
2020-05-04 12:44:12 +02:00
|
|
|
apiClient.sendMessage('SessionsStop');
|
2019-01-10 15:39:37 +03:00
|
|
|
if (instance.pollInterval) {
|
|
|
|
clearInterval(instance.pollInterval);
|
|
|
|
instance.pollInterval = null;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function processUpdatedSessions(instance, sessions, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var serverId = apiClient.serverId();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
sessions.map(function (s) {
|
|
|
|
if (s.NowPlayingItem) {
|
|
|
|
s.NowPlayingItem.ServerId = serverId;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var currentTargetId = getActivePlayerId();
|
|
|
|
|
|
|
|
var session = sessions.filter(function (s) {
|
|
|
|
return s.Id === currentTargetId;
|
|
|
|
})[0];
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
if (session) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
normalizeImages(session, apiClient);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var eventNames = getChangedEvents(instance.lastPlayerData, session);
|
|
|
|
instance.lastPlayerData = session;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
for (var i = 0, length = eventNames.length; i < length; i++) {
|
|
|
|
events.trigger(instance, eventNames[i], [session]);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
instance.lastPlayerData = session;
|
|
|
|
|
|
|
|
playbackManager.setDefaultPlayerActive();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getChangedEvents(state1, state2) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var names = [];
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (!state1) {
|
|
|
|
names.push('statechange');
|
|
|
|
names.push('timeupdate');
|
|
|
|
names.push('pause');
|
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Trim these down to prevent the UI from over-refreshing
|
|
|
|
names.push('statechange');
|
|
|
|
names.push('timeupdate');
|
|
|
|
names.push('pause');
|
|
|
|
|
|
|
|
return names;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onPollIntervalFired() {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var instance = this;
|
|
|
|
var apiClient = getCurrentApiClient(instance);
|
|
|
|
if (!apiClient.isMessageChannelOpen()) {
|
|
|
|
|
|
|
|
apiClient.getSessions().then(function (sessions) {
|
|
|
|
processUpdatedSessions(instance, sessions, apiClient);
|
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeToPlayerUpdates(instance) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
instance.isUpdating = true;
|
|
|
|
|
|
|
|
var apiClient = getCurrentApiClient(instance);
|
2020-05-04 12:44:12 +02:00
|
|
|
apiClient.sendMessage('SessionsStart', '100,800');
|
2019-01-10 15:39:37 +03:00
|
|
|
if (instance.pollInterval) {
|
|
|
|
clearInterval(instance.pollInterval);
|
|
|
|
instance.pollInterval = null;
|
|
|
|
}
|
|
|
|
instance.pollInterval = setInterval(onPollIntervalFired.bind(instance), 5000);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function normalizeImages(state, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
if (state && state.NowPlayingItem) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var item = state.NowPlayingItem;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (!item.ImageTags || !item.ImageTags.Primary) {
|
|
|
|
if (item.PrimaryImageTag) {
|
|
|
|
item.ImageTags = item.ImageTags || {};
|
|
|
|
item.ImageTags.Primary = item.PrimaryImageTag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item.BackdropImageTag && item.BackdropItemId === item.Id) {
|
|
|
|
item.BackdropImageTags = [item.BackdropImageTag];
|
|
|
|
}
|
|
|
|
if (item.BackdropImageTag && item.BackdropItemId !== item.Id) {
|
|
|
|
item.ParentBackdropImageTags = [item.BackdropImageTag];
|
|
|
|
item.ParentBackdropItemId = item.BackdropItemId;
|
|
|
|
}
|
|
|
|
if (!item.ServerId) {
|
|
|
|
item.ServerId = apiClient.serverId();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function SessionPlayer() {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var self = this;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
this.name = 'Remote Control';
|
|
|
|
this.type = 'mediaplayer';
|
|
|
|
this.isLocalPlayer = false;
|
|
|
|
this.id = 'remoteplayer';
|
|
|
|
|
|
|
|
events.on(serverNotifications, 'Sessions', function (e, apiClient, data) {
|
|
|
|
processUpdatedSessions(self, data, apiClient);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
SessionPlayer.prototype.beginPlayerUpdates = function () {
|
|
|
|
|
|
|
|
this.playerListenerCount = this.playerListenerCount || 0;
|
|
|
|
|
|
|
|
if (this.playerListenerCount <= 0) {
|
|
|
|
|
|
|
|
this.playerListenerCount = 0;
|
|
|
|
|
|
|
|
subscribeToPlayerUpdates(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.playerListenerCount++;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.endPlayerUpdates = function () {
|
|
|
|
|
|
|
|
this.playerListenerCount = this.playerListenerCount || 0;
|
|
|
|
this.playerListenerCount--;
|
|
|
|
|
|
|
|
if (this.playerListenerCount <= 0) {
|
|
|
|
|
|
|
|
unsubscribeFromPlayerUpdates(this);
|
|
|
|
this.playerListenerCount = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getPlayerState = function () {
|
|
|
|
|
|
|
|
return this.lastPlayerData || {};
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getTargets = function () {
|
|
|
|
|
|
|
|
var apiClient = getCurrentApiClient(this);
|
|
|
|
|
|
|
|
var sessionQuery = {
|
|
|
|
ControllableByUserId: apiClient.getCurrentUserId()
|
|
|
|
};
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
if (apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var name = this.name;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return apiClient.getSessions(sessionQuery).then(function (sessions) {
|
|
|
|
|
|
|
|
return sessions.filter(function (s) {
|
|
|
|
return s.DeviceId !== apiClient.deviceId();
|
|
|
|
|
|
|
|
}).map(function (s) {
|
2018-10-23 01:05:09 +03:00
|
|
|
return {
|
|
|
|
name: s.DeviceName,
|
|
|
|
deviceName: s.DeviceName,
|
|
|
|
deviceType: s.DeviceType,
|
|
|
|
id: s.Id,
|
|
|
|
playerName: name,
|
|
|
|
appName: s.Client,
|
|
|
|
playableMediaTypes: s.PlayableMediaTypes,
|
2019-01-10 15:39:37 +03:00
|
|
|
isLocalPlayer: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
supportedCommands: s.SupportedCommands,
|
|
|
|
user: s.UserId ? {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
Id: s.UserId,
|
|
|
|
Name: s.UserName,
|
|
|
|
PrimaryImageTag: s.UserPrimaryImageTag
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
} : null
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return Promise.resolve([]);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.sendCommand = function (command) {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var sessionId = getActivePlayerId();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var apiClient = getCurrentApiClient(this);
|
|
|
|
apiClient.sendCommand(sessionId, command);
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.play = function (options) {
|
|
|
|
|
|
|
|
options = Object.assign({}, options);
|
|
|
|
|
|
|
|
if (options.items) {
|
|
|
|
options.ids = options.items.map(function (i) {
|
|
|
|
return i.Id;
|
|
|
|
});
|
|
|
|
|
|
|
|
options.items = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sendPlayCommand(getCurrentApiClient(this), options, 'PlayNow');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.shuffle = function (item) {
|
|
|
|
|
|
|
|
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.instantMix = function (item) {
|
|
|
|
|
|
|
|
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.queue = function (options) {
|
|
|
|
|
|
|
|
sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.queueNext = function (options) {
|
|
|
|
|
|
|
|
sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.canPlayMediaType = function (mediaType) {
|
|
|
|
|
|
|
|
mediaType = (mediaType || '').toLowerCase();
|
|
|
|
return mediaType === 'audio' || mediaType === 'video';
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.canQueueMediaType = function (mediaType) {
|
|
|
|
return this.canPlayMediaType(mediaType);
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.stop = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'stop');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.nextTrack = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'nextTrack');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.previousTrack = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'previousTrack');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.seek = function (positionTicks) {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'seek',
|
|
|
|
{
|
|
|
|
SeekPositionTicks: positionTicks
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.currentTime = function (val) {
|
|
|
|
|
|
|
|
if (val != null) {
|
|
|
|
return this.seek(val);
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.PositionTicks;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.duration = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.NowPlayingItem || {};
|
|
|
|
return state.RunTimeTicks;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.paused = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.IsPaused;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getVolume = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.VolumeLevel;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.isMuted = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.IsMuted;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.pause = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'Pause');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.unpause = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'Unpause');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.playPause = function () {
|
|
|
|
sendPlayStateCommand(getCurrentApiClient(this), 'PlayPause');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.setMute = function (isMuted) {
|
|
|
|
|
|
|
|
if (isMuted) {
|
|
|
|
sendCommandByName(this, 'Mute');
|
|
|
|
} else {
|
|
|
|
sendCommandByName(this, 'Unmute');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.toggleMute = function () {
|
|
|
|
sendCommandByName(this, 'ToggleMute');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.setVolume = function (vol) {
|
|
|
|
sendCommandByName(this, 'SetVolume', {
|
2018-10-23 01:05:09 +03:00
|
|
|
Volume: vol
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.volumeUp = function () {
|
|
|
|
sendCommandByName(this, 'VolumeUp');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.volumeDown = function () {
|
|
|
|
sendCommandByName(this, 'VolumeDown');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.toggleFullscreen = function () {
|
|
|
|
sendCommandByName(this, 'ToggleFullscreen');
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.audioTracks = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.NowPlayingItem || {};
|
|
|
|
var streams = state.MediaStreams || [];
|
|
|
|
return streams.filter(function (s) {
|
|
|
|
return s.Type === 'Audio';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getAudioStreamIndex = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.AudioStreamIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.playTrailers = function (item) {
|
|
|
|
sendCommandByName(this, 'PlayTrailers', {
|
2018-10-23 01:05:09 +03:00
|
|
|
ItemId: item.Id
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.setAudioStreamIndex = function (index) {
|
|
|
|
sendCommandByName(this, 'SetAudioStreamIndex', {
|
2018-10-23 01:05:09 +03:00
|
|
|
Index: index
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.subtitleTracks = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.NowPlayingItem || {};
|
|
|
|
var streams = state.MediaStreams || [];
|
|
|
|
return streams.filter(function (s) {
|
|
|
|
return s.Type === 'Subtitle';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getSubtitleStreamIndex = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.PlayState || {};
|
|
|
|
return state.SubtitleStreamIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.setSubtitleStreamIndex = function (index) {
|
|
|
|
sendCommandByName(this, 'SetSubtitleStreamIndex', {
|
2018-10-23 01:05:09 +03:00
|
|
|
Index: index
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getMaxStreamingBitrate = function () {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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', {
|
2018-10-23 01:05:09 +03:00
|
|
|
RepeatMode: mode
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-06-22 11:25:16 +02:00
|
|
|
SessionPlayer.prototype.setQueueShuffleMode = function (mode) {
|
2020-06-18 01:19:59 +02:00
|
|
|
|
2020-06-22 11:25:16 +02:00
|
|
|
sendCommandByName(this, 'SetQueueShuffleMode', {
|
2020-06-18 01:19:59 +02:00
|
|
|
ShuffleMode: mode
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-06-22 11:25:16 +02:00
|
|
|
SessionPlayer.prototype.getQueueShuffleMode = function () {
|
2020-06-22 11:10:26 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
SessionPlayer.prototype.displayContent = function (options) {
|
|
|
|
|
|
|
|
sendCommandByName(this, 'DisplayContent', options);
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.isPlaying = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
return state.NowPlayingItem != null;
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.isPlayingVideo = function () {
|
|
|
|
var state = this.lastPlayerData || {};
|
|
|
|
state = state.NowPlayingItem || {};
|
|
|
|
return state.MediaType === 'Video';
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.isPlayingAudio = function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var state = this.lastPlayerData || {};
|
2019-01-10 15:39:37 +03:00
|
|
|
state = state.NowPlayingItem || {};
|
|
|
|
return state.MediaType === 'Audio';
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getPlaylist = function () {
|
|
|
|
return Promise.resolve([]);
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.getCurrentPlaylistItemId = function () {
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.setCurrentPlaylistItem = function (playlistItemId) {
|
|
|
|
return Promise.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.removeFromPlaylist = function (playlistItemIds) {
|
|
|
|
return Promise.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
SessionPlayer.prototype.tryPair = function (target) {
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
return SessionPlayer;
|
2020-02-22 11:47:03 -05:00
|
|
|
});
|