mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
support sending nav commands
This commit is contained in:
parent
d619275f90
commit
093ee4c866
7 changed files with 138 additions and 32 deletions
|
@ -48,7 +48,6 @@
|
|||
<button data-inline="true" data-iconpos="right" title="${ButtonLetterDown}" data-icon="minus" class="btnLetterDown btnCommand ui-nodisc-icon" data-command="PreviousLetter">${LetterButtonAbbreviation}</button>
|
||||
<button data-icon="camera" data-inline="true" data-iconpos="notext" title="${ButtonTakeScreenshot}" class="btnScreenshot btnCommand" data-command="TakeScreenshot">${ButtonTakeScreenshot}</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1374,6 +1374,44 @@
|
|||
castPlayer.setReceiverVolume(false, vol / 100);
|
||||
};
|
||||
|
||||
self.sendCommand = function (cmd) {
|
||||
|
||||
// Full list
|
||||
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
|
||||
|
||||
switch (cmd.Name) {
|
||||
|
||||
case 'VolumeUp':
|
||||
self.volumeUp();
|
||||
break;
|
||||
case 'VolumeDown':
|
||||
self.volumeDown();
|
||||
break;
|
||||
case 'Mute':
|
||||
self.mute();
|
||||
break;
|
||||
case 'Unmute':
|
||||
self.unMute();
|
||||
break;
|
||||
case 'ToggleMute':
|
||||
self.toggleMute();
|
||||
break;
|
||||
case 'SetVolume':
|
||||
self.setVolume(cmd.Arguments.Volume);
|
||||
break;
|
||||
case 'SetAudioStreamIndex':
|
||||
break;
|
||||
case 'SetSubtitleStreamIndex':
|
||||
break;
|
||||
case 'ToggleFullscreen':
|
||||
break;
|
||||
default:
|
||||
// Not player-related
|
||||
Dashboard.processGeneralCommand(cmd);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
self.getPlayerState = function () {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
|
|
@ -726,6 +726,49 @@
|
|||
});
|
||||
};
|
||||
|
||||
self.sendCommand = function (cmd) {
|
||||
|
||||
// Full list
|
||||
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
|
||||
|
||||
switch (cmd.Name) {
|
||||
|
||||
case 'VolumeUp':
|
||||
self.volumeUp();
|
||||
break;
|
||||
case 'VolumeDown':
|
||||
self.volumeDown();
|
||||
break;
|
||||
case 'Mute':
|
||||
self.mute();
|
||||
break;
|
||||
case 'Unmute':
|
||||
self.unMute();
|
||||
break;
|
||||
case 'ToggleMute':
|
||||
self.toggleMute();
|
||||
break;
|
||||
case 'SetVolume':
|
||||
self.setVolume(cmd.Arguments.Volume);
|
||||
break;
|
||||
case 'SetAudioStreamIndex':
|
||||
break;
|
||||
case 'SetSubtitleStreamIndex':
|
||||
break;
|
||||
case 'ToggleFullscreen':
|
||||
|
||||
if (currentItem && currentItem.MediaType == 'Video') {
|
||||
self.toggleFullscreen();
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// Not player-related
|
||||
Dashboard.processGeneralCommand(cmd);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
self.pause = function () {
|
||||
|
||||
currentMediaElement.pause();
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
$('.btnCommand', page).on('click', function () {
|
||||
|
||||
|
||||
currentPlayer.sendCommand({
|
||||
Name: this.getAttribute('data-command')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,7 @@
|
|||
|
||||
var page = this;
|
||||
|
||||
$('.radioTabButton', page).checked(false).checkboxradio('refresh');
|
||||
$('.radioTabButton:first', page).checked(true).checkboxradio('refresh').trigger('change');
|
||||
|
||||
$(function () {
|
||||
|
|
|
@ -28,19 +28,32 @@
|
|||
ApiClient.sendPlayStateCommand(sessionId, command, options);
|
||||
}
|
||||
|
||||
function sendCommand(command, options) {
|
||||
|
||||
var sessionId = MediaController.getPlayerInfo().id;
|
||||
|
||||
ApiClient.sendCommand(sessionId, command, options);
|
||||
}
|
||||
|
||||
function remoteControlPlayer() {
|
||||
|
||||
var self = this;
|
||||
|
||||
self.name = 'Remote Control';
|
||||
|
||||
function sendCommandByName(name, options) {
|
||||
|
||||
var command = {
|
||||
Name: name
|
||||
};
|
||||
|
||||
if (options) {
|
||||
command.Arguments = options;
|
||||
}
|
||||
|
||||
self.sendCommand(command);
|
||||
}
|
||||
|
||||
self.sendCommand = function (command) {
|
||||
|
||||
var sessionId = MediaController.getPlayerInfo().id;
|
||||
|
||||
ApiClient.sendCommand(sessionId, command);
|
||||
};
|
||||
|
||||
self.play = function (options) {
|
||||
|
||||
sendPlayCommand(options, 'PlayNow');
|
||||
|
@ -99,19 +112,19 @@
|
|||
};
|
||||
|
||||
self.mute = function () {
|
||||
sendCommand('Mute');
|
||||
sendCommandByName('Mute');
|
||||
};
|
||||
|
||||
self.unMute = function () {
|
||||
sendCommand('Unmute');
|
||||
sendCommandByName('Unmute');
|
||||
};
|
||||
|
||||
self.toggleMute = function () {
|
||||
sendCommand('ToggleMute');
|
||||
sendCommandByName('ToggleMute');
|
||||
};
|
||||
|
||||
self.setVolume = function (vol) {
|
||||
sendCommand('SetVolume', {
|
||||
sendCommandByName('SetVolume', {
|
||||
|
||||
Volume: vol
|
||||
|
||||
|
@ -120,7 +133,7 @@
|
|||
|
||||
self.displayContent = function (options) {
|
||||
|
||||
sendCommand('DisplayContent', {
|
||||
sendCommandByName('DisplayContent', {
|
||||
|
||||
ItemName: options.itemName,
|
||||
ItemType: options.itemType,
|
||||
|
|
|
@ -830,6 +830,28 @@ var Dashboard = {
|
|||
|
||||
},
|
||||
|
||||
processGeneralCommand: function (cmd) {
|
||||
|
||||
// Full list
|
||||
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
|
||||
|
||||
if (cmd.Name === 'GoHome') {
|
||||
Dashboard.navigate('index.html');
|
||||
}
|
||||
else if (cmd.Name === 'GoToSettings') {
|
||||
Dashboard.navigate('dashboard.html');
|
||||
}
|
||||
else if (cmd.Name === 'DisplayContent') {
|
||||
Dashboard.onBrowseCommand(cmd.Arguments);
|
||||
}
|
||||
else if (cmd.Name === 'GoToSearch') {
|
||||
Search.showSearchPanel($.mobile.activePage);
|
||||
}
|
||||
else {
|
||||
console.log('Unrecognized command: ' + cmd.Name);
|
||||
}
|
||||
},
|
||||
|
||||
onWebSocketMessageReceived: function (e, data) {
|
||||
|
||||
var msg = data;
|
||||
|
@ -911,15 +933,7 @@ var Dashboard = {
|
|||
|
||||
var cmd = msg.Data;
|
||||
|
||||
if (cmd.Name === 'GoHome') {
|
||||
Dashboard.navigate('index.html');
|
||||
}
|
||||
else if (cmd.Name === 'GoToSettings') {
|
||||
Dashboard.navigate('dashboard.html');
|
||||
}
|
||||
else if (cmd.Name === 'DisplayContent') {
|
||||
Dashboard.onBrowseCommand(cmd.Arguments);
|
||||
}
|
||||
Dashboard.processGeneralCommand(cmd);
|
||||
}
|
||||
else if (msg.MessageType === "MessageCommand") {
|
||||
|
||||
|
@ -1283,7 +1297,8 @@ var Dashboard = {
|
|||
"ToggleFullscreen",
|
||||
"SetAudioStreamIndex",
|
||||
"SetSubtitleStreamIndex",
|
||||
"DisplayContent"
|
||||
"DisplayContent",
|
||||
"GoToSearch"
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -3057,7 +3057,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
});
|
||||
};
|
||||
|
||||
self.sendCommand = function (sessionId, command, options) {
|
||||
self.sendCommand = function (sessionId, command) {
|
||||
|
||||
if (!sessionId) {
|
||||
throw new Error("null sessionId");
|
||||
|
@ -3074,12 +3074,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
url: url
|
||||
};
|
||||
|
||||
options = {
|
||||
Arguments: options || {},
|
||||
Name: command
|
||||
};
|
||||
|
||||
ajaxOptions.data = JSON.stringify(options);
|
||||
ajaxOptions.data = JSON.stringify(command);
|
||||
ajaxOptions.contentType = "application/json";
|
||||
|
||||
return self.ajax(ajaxOptions);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue