2014-03-29 08:40:32 -07:00
|
|
|
|
(function ($, window) {
|
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
var enableMirrorMode;
|
|
|
|
|
var currentDisplayInfo;
|
2014-04-15 19:17:48 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
function mirrorItem(info) {
|
|
|
|
|
|
|
|
|
|
var item = info.item;
|
2014-04-15 19:17:48 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
MediaController.getCurrentPlayer().displayContent({
|
|
|
|
|
|
|
|
|
|
itemName: item.Name,
|
|
|
|
|
itemId: item.Id,
|
|
|
|
|
itemType: item.Type,
|
|
|
|
|
context: info.context
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 17:50:47 -07:00
|
|
|
|
function monitorPlayer(player) {
|
|
|
|
|
|
|
|
|
|
$(player).on('playbackstart.mediacontroller', function (e, state) {
|
|
|
|
|
|
|
|
|
|
var info = {
|
|
|
|
|
QueueableMediaTypes: state.NowPlayingItem.MediaType,
|
|
|
|
|
ItemId: state.NowPlayingItem.Id,
|
|
|
|
|
NowPlayingItem: state.NowPlayingItem
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
info = $.extend(info, state.PlayState);
|
|
|
|
|
|
|
|
|
|
ApiClient.reportPlaybackStart(info);
|
|
|
|
|
|
|
|
|
|
}).on('playbackstop.mediacontroller', function (e, state) {
|
|
|
|
|
|
|
|
|
|
ApiClient.reportPlaybackStopped({
|
|
|
|
|
|
|
|
|
|
itemId: state.NowPlayingItem.Id,
|
|
|
|
|
mediaSourceId: state.PlayState.MediaSourceId,
|
|
|
|
|
positionTicks: state.PlayState.PositionTicks
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('positionchange.mediacontroller', function (e, state) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
function mediaController() {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
var currentPlayer;
|
2014-03-29 09:58:49 -07:00
|
|
|
|
var currentTargetInfo;
|
2014-03-29 08:40:32 -07:00
|
|
|
|
var players = [];
|
|
|
|
|
|
|
|
|
|
self.registerPlayer = function (player) {
|
|
|
|
|
|
|
|
|
|
players.push(player);
|
2014-04-22 17:50:47 -07:00
|
|
|
|
|
|
|
|
|
if (player.isLocalPlayer) {
|
|
|
|
|
monitorPlayer(player);
|
|
|
|
|
}
|
2014-03-29 09:58:49 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.getPlayerInfo = function () {
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
|
|
name: currentPlayer.name,
|
|
|
|
|
isLocalPlayer: currentPlayer.isLocalPlayer,
|
2014-03-29 11:20:42 -07:00
|
|
|
|
id: currentTargetInfo.id,
|
|
|
|
|
deviceName: currentTargetInfo.deviceName,
|
2014-04-14 20:54:52 -07:00
|
|
|
|
playableMediaTypes: currentTargetInfo.playableMediaTypes,
|
|
|
|
|
supportedCommands: currentTargetInfo.supportedCommands
|
2014-03-29 09:58:49 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.setActivePlayer = function (player, targetInfo) {
|
|
|
|
|
|
|
|
|
|
if (typeof (player) === 'string') {
|
|
|
|
|
player = players.filter(function (p) {
|
|
|
|
|
return p.name == player;
|
|
|
|
|
})[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!player) {
|
|
|
|
|
throw new Error('null player');
|
|
|
|
|
}
|
2014-03-29 08:40:32 -07:00
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
currentPlayer = player;
|
2014-04-05 10:01:04 -07:00
|
|
|
|
currentTargetInfo = targetInfo || player.getCurrentTargetInfo();
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
$(self).trigger('playerchange');
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
self.setDefaultPlayerActive = function () {
|
2014-04-06 10:53:23 -07:00
|
|
|
|
self.setActivePlayer(self.getDefaultPlayer());
|
2014-04-05 10:01:04 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.removeActivePlayer = function (name) {
|
2014-04-12 10:27:53 -07:00
|
|
|
|
|
2014-04-05 10:01:04 -07:00
|
|
|
|
if (self.getPlayerInfo().name == name) {
|
2014-04-06 10:53:23 -07:00
|
|
|
|
self.setDefaultPlayerActive();
|
2014-04-05 10:01:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
self.getTargets = function () {
|
|
|
|
|
|
|
|
|
|
var deferred = $.Deferred();
|
|
|
|
|
|
|
|
|
|
var promises = players.map(function (p) {
|
|
|
|
|
return p.getTargets();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$.when.apply($, promises).done(function () {
|
|
|
|
|
|
|
|
|
|
var targets = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
|
|
|
|
|
|
|
var subTargets = arguments[i];
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < subTargets.length; j++) {
|
|
|
|
|
|
|
|
|
|
targets.push(subTargets[j]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
targets = targets.sort(function (a, b) {
|
2014-04-05 10:01:04 -07:00
|
|
|
|
|
|
|
|
|
var aVal = a.isLocalPlayer ? 0 : 1;
|
|
|
|
|
var bVal = b.isLocalPlayer ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
aVal = aVal.toString() + a.name;
|
|
|
|
|
bVal = bVal.toString() + b.name;
|
|
|
|
|
|
|
|
|
|
return aVal.localeCompare(bVal);
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
deferred.resolveWith(null, [targets]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return deferred.promise();
|
2014-03-29 08:40:32 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.play = function (options) {
|
|
|
|
|
|
|
|
|
|
if (typeof (options) === 'string') {
|
|
|
|
|
options = { ids: [options] };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentPlayer.play(options);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.shuffle = function (id) {
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
currentPlayer.shuffle(id);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.instantMix = function (id) {
|
|
|
|
|
currentPlayer.instantMix(id);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.queue = function (options) {
|
|
|
|
|
|
|
|
|
|
if (typeof (options) === 'string') {
|
|
|
|
|
options = { ids: [options] };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentPlayer.queue(options);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.queueNext = function (options) {
|
|
|
|
|
|
|
|
|
|
if (typeof (options) === 'string') {
|
|
|
|
|
options = { ids: [options] };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentPlayer.queueNext(options);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.canPlay = function (item) {
|
|
|
|
|
|
|
|
|
|
if (item.PlayAccess != 'Full') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.LocationType == "Virtual" || item.IsPlaceHolder) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.IsFolder || item.Type == "MusicGenre") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
return self.getPlayerInfo().playableMediaTypes.indexOf(item.MediaType) != -1;
|
2014-03-29 08:40:32 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.canQueueMediaType = function (mediaType) {
|
|
|
|
|
|
|
|
|
|
return currentPlayer.canQueueMediaType(mediaType);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.getLocalPlayer = function () {
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
return currentPlayer.isLocalPlayer ?
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
currentPlayer :
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
players.filter(function (p) {
|
|
|
|
|
return p.isLocalPlayer;
|
|
|
|
|
})[0];
|
|
|
|
|
};
|
2014-04-06 10:53:23 -07:00
|
|
|
|
|
|
|
|
|
self.getDefaultPlayer = function () {
|
|
|
|
|
|
|
|
|
|
return currentPlayer.isLocalPlayer ?
|
|
|
|
|
|
|
|
|
|
currentPlayer :
|
|
|
|
|
|
|
|
|
|
players.filter(function (p) {
|
|
|
|
|
return p.isDefaultPlayer;
|
|
|
|
|
})[0];
|
|
|
|
|
};
|
2014-04-09 16:58:09 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
self.getCurrentPlayer = function () {
|
|
|
|
|
|
|
|
|
|
return currentPlayer;
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-09 16:58:09 -07:00
|
|
|
|
self.pause = function () {
|
|
|
|
|
currentPlayer.pause();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.stop = function () {
|
|
|
|
|
currentPlayer.stop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.unpause = function () {
|
|
|
|
|
currentPlayer.unpause();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.seek = function (position) {
|
2014-04-11 08:36:25 -07:00
|
|
|
|
currentPlayer.seek(position);
|
2014-04-09 16:58:09 -07:00
|
|
|
|
};
|
2014-04-09 21:12:04 -07:00
|
|
|
|
|
|
|
|
|
self.currentPlaylistIndex = function (i) {
|
2014-04-10 04:12:48 -07:00
|
|
|
|
currentPlayer.currentPlaylistIndex(i);
|
2014-04-09 21:12:04 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.removeFromPlaylist = function (i) {
|
2014-04-10 04:12:48 -07:00
|
|
|
|
currentPlayer.removeFromPlaylist(i);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.nextTrack = function () {
|
|
|
|
|
currentPlayer.nextTrack();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.previousTrack = function () {
|
|
|
|
|
currentPlayer.previousTrack();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.mute = function () {
|
|
|
|
|
currentPlayer.mute();
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-15 20:49:49 -07:00
|
|
|
|
self.unMute = function () {
|
|
|
|
|
currentPlayer.unMute();
|
2014-04-10 04:12:48 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.toggleMute = function () {
|
|
|
|
|
currentPlayer.toggleMute();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.volumeDown = function () {
|
|
|
|
|
currentPlayer.volumeDown();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.volumeUp = function () {
|
|
|
|
|
currentPlayer.volumeUp();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.shuffle = function (id) {
|
|
|
|
|
currentPlayer.shuffle(id);
|
2014-04-09 21:12:04 -07:00
|
|
|
|
};
|
2014-03-29 08:40:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.MediaController = new mediaController();
|
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
function onWebSocketMessageReceived(e, msg) {
|
2014-03-29 08:40:32 -07:00
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
var localPlayer;
|
2014-03-29 08:40:32 -07:00
|
|
|
|
|
|
|
|
|
if (msg.MessageType === "Play") {
|
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
localPlayer = MediaController.getLocalPlayer();
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
if (msg.Data.PlayCommand == "PlayNext") {
|
|
|
|
|
localPlayer.queueNext({ ids: msg.Data.ItemIds });
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.PlayCommand == "PlayLast") {
|
|
|
|
|
localPlayer.queue({ ids: msg.Data.ItemIds });
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
localPlayer.play({ ids: msg.Data.ItemIds, startPositionTicks: msg.Data.StartPositionTicks });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2014-04-06 10:53:23 -07:00
|
|
|
|
else if (msg.MessageType === "ServerShuttingDown") {
|
|
|
|
|
MediaController.setDefaultPlayerActive();
|
|
|
|
|
}
|
|
|
|
|
else if (msg.MessageType === "ServerRestarting") {
|
|
|
|
|
MediaController.setDefaultPlayerActive();
|
|
|
|
|
}
|
2014-03-29 08:40:32 -07:00
|
|
|
|
else if (msg.MessageType === "Playstate") {
|
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
localPlayer = MediaController.getLocalPlayer();
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
if (msg.Data.Command === 'Stop') {
|
|
|
|
|
localPlayer.stop();
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.Command === 'Pause') {
|
|
|
|
|
localPlayer.pause();
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.Command === 'Unpause') {
|
|
|
|
|
localPlayer.unpause();
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.Command === 'Seek') {
|
|
|
|
|
localPlayer.seek(msg.Data.SeekPositionTicks);
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.Command === 'NextTrack') {
|
|
|
|
|
localPlayer.nextTrack();
|
|
|
|
|
}
|
|
|
|
|
else if (msg.Data.Command === 'PreviousTrack') {
|
|
|
|
|
localPlayer.previousTrack();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-31 14:04:22 -07:00
|
|
|
|
else if (msg.MessageType === "GeneralCommand") {
|
|
|
|
|
|
|
|
|
|
var cmd = msg.Data;
|
|
|
|
|
|
2014-04-12 10:27:53 -07:00
|
|
|
|
localPlayer = MediaController.getLocalPlayer();
|
|
|
|
|
|
2014-03-31 14:04:22 -07:00
|
|
|
|
if (cmd.Name === 'Mute') {
|
|
|
|
|
localPlayer.mute();
|
|
|
|
|
}
|
|
|
|
|
else if (cmd.Name === 'Unmute') {
|
2014-04-05 10:01:04 -07:00
|
|
|
|
localPlayer.unMute();
|
2014-03-31 14:04:22 -07:00
|
|
|
|
}
|
|
|
|
|
else if (cmd.Name === 'VolumeUp') {
|
|
|
|
|
localPlayer.volumeUp();
|
|
|
|
|
}
|
|
|
|
|
else if (cmd.Name === 'VolumeDown') {
|
|
|
|
|
localPlayer.volumeDown();
|
|
|
|
|
}
|
|
|
|
|
else if (cmd.Name === 'ToggleMute') {
|
|
|
|
|
localPlayer.toggleMute();
|
|
|
|
|
}
|
2014-04-13 10:27:13 -07:00
|
|
|
|
else if (cmd.Name === 'Fullscreen') {
|
2014-04-12 10:27:53 -07:00
|
|
|
|
localPlayer.remoteFullscreen();
|
|
|
|
|
}
|
2014-04-13 10:27:13 -07:00
|
|
|
|
else if (cmd.Name === 'SetVolume') {
|
|
|
|
|
localPlayer.setVolume(parseFloat(cmd.Arguments.Volume));
|
2014-04-12 10:27:53 -07:00
|
|
|
|
}
|
2014-03-31 14:04:22 -07:00
|
|
|
|
}
|
2014-03-29 08:40:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(ApiClient).on("websocketmessage", onWebSocketMessageReceived);
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
function getTargetsHtml(targets) {
|
|
|
|
|
|
|
|
|
|
var playerInfo = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
var html = '';
|
2014-04-13 10:27:13 -07:00
|
|
|
|
html += '<form>';
|
|
|
|
|
|
|
|
|
|
html += '<form><h3>Select Player:</h3>';
|
2014-03-29 09:58:49 -07:00
|
|
|
|
html += '<fieldset data-role="controlgroup" data-mini="true">';
|
|
|
|
|
|
2014-04-15 19:17:48 -07:00
|
|
|
|
var checkedHtml;
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
for (var i = 0, length = targets.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var target = targets[i];
|
|
|
|
|
|
|
|
|
|
var id = 'radioPlayerTarget' + i;
|
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
var isChecked = target.id == playerInfo.id;
|
2014-04-15 19:17:48 -07:00
|
|
|
|
checkedHtml = isChecked ? ' checked="checked"' : '';
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
var mirror = (!target.isLocalPlayer && target.supportedCommands.indexOf('DisplayContent') != -1) ? 'true' : 'false';
|
|
|
|
|
|
2014-04-14 20:54:52 -07:00
|
|
|
|
html += '<input type="radio" class="radioSelectPlayerTarget" name="radioSelectPlayerTarget" data-mirror="' + mirror + '" data-commands="' + target.supportedCommands.join(',') + '" data-mediatypes="' + target.playableMediaTypes.join(',') + '" data-playername="' + target.playerName + '" data-targetid="' + target.id + '" data-targetname="' + target.name + '" id="' + id + '" value="' + target.id + '"' + checkedHtml + '>';
|
2014-03-29 11:20:42 -07:00
|
|
|
|
html += '<label for="' + id + '" style="font-weight:normal;">' + target.name;
|
|
|
|
|
|
|
|
|
|
if (target.appName) {
|
|
|
|
|
html += '<br/><span style="color:#bbb;">' + target.appName + '</span>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</label>';
|
2014-03-29 09:58:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</fieldset>';
|
2014-03-30 09:49:40 -07:00
|
|
|
|
|
|
|
|
|
html += '<p class="fieldDescription">All plays will be sent to the selected player.</p>';
|
|
|
|
|
|
2014-04-15 19:17:48 -07:00
|
|
|
|
checkedHtml = enableMirrorMode ? ' checked="checked"' : '';
|
2014-04-21 09:02:30 -07:00
|
|
|
|
html += '<div style="margin-top:1.5em;" class="fldMirrorMode"><label for="chkEnableMirrorMode">Enable display mirroring</label><input type="checkbox" class="chkEnableMirrorMode" id="chkEnableMirrorMode" data-mini="true"' + checkedHtml + ' /></div>';
|
2014-04-13 10:27:13 -07:00
|
|
|
|
|
|
|
|
|
html += '</form>';
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-30 09:49:40 -07:00
|
|
|
|
function showPlayerSelection(page) {
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
var promise = MediaController.getTargets();
|
2014-03-31 14:04:22 -07:00
|
|
|
|
|
2014-03-30 09:49:40 -07:00
|
|
|
|
var html = '<div data-role="panel" data-position="right" data-display="overlay" data-position-fixed="true" id="playerSelectionPanel" class="playerSelectionPanel" data-theme="b">';
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
html += '<div class="players"></div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$(document.body).append(html);
|
|
|
|
|
|
2014-03-30 09:49:40 -07:00
|
|
|
|
var elem = $('#playerSelectionPanel').panel({}).trigger('create').panel("open").on("panelafterclose", function () {
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
$(this).off("panelafterclose").remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
promise.done(function (targets) {
|
|
|
|
|
|
|
|
|
|
$('.players', elem).html(getTargetsHtml(targets)).trigger('create');
|
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
$('.chkEnableMirrorMode', elem).on().on('change', function () {
|
|
|
|
|
enableMirrorMode = this.checked;
|
2014-04-15 19:17:48 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
if (this.checked && currentDisplayInfo) {
|
|
|
|
|
|
|
|
|
|
mirrorItem(currentDisplayInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
$('.radioSelectPlayerTarget', elem).on('change', function () {
|
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
var supportsMirror = this.getAttribute('data-mirror') == 'true';
|
|
|
|
|
|
|
|
|
|
if (supportsMirror) {
|
|
|
|
|
$('.fldMirrorMode', elem).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldMirrorMode', elem).hide();
|
|
|
|
|
$('.chkEnableMirrorMode', elem).checked(false).trigger('change').checkboxradio('refresh');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).each(function () {
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
$(this).trigger('change');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).on('change', function () {
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
var playerName = this.getAttribute('data-playername');
|
|
|
|
|
var targetId = this.getAttribute('data-targetid');
|
|
|
|
|
var targetName = this.getAttribute('data-targetname');
|
2014-03-29 11:20:42 -07:00
|
|
|
|
var playableMediaTypes = this.getAttribute('data-mediatypes').split(',');
|
2014-04-14 20:54:52 -07:00
|
|
|
|
var supportedCommands = this.getAttribute('data-commands').split(',');
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
MediaController.setActivePlayer(playerName, {
|
|
|
|
|
id: targetId,
|
2014-03-29 11:20:42 -07:00
|
|
|
|
name: targetName,
|
2014-04-14 20:54:52 -07:00
|
|
|
|
playableMediaTypes: playableMediaTypes,
|
|
|
|
|
supportedCommands: supportedCommands
|
2014-03-29 09:58:49 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('headercreated', ".libraryPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.btnCast', page).on('click', function () {
|
|
|
|
|
|
2014-03-30 09:49:40 -07:00
|
|
|
|
showPlayerSelection(page);
|
2014-03-29 09:58:49 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
$(document).on('pagebeforeshow', ".page", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
currentDisplayInfo = null;
|
|
|
|
|
|
|
|
|
|
}).on('displayingitem', ".libraryPage", function (e, info) {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
currentDisplayInfo = info;
|
|
|
|
|
|
|
|
|
|
if (enableMirrorMode) {
|
|
|
|
|
mirrorItem(info);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
})(jQuery, window);
|