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-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>
|
<button data-icon="camera" data-inline="true" data-iconpos="notext" title="${ButtonTakeScreenshot}" class="btnScreenshot btnCommand" data-command="TakeScreenshot">${ButtonTakeScreenshot}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1374,6 +1374,44 @@
|
||||||
castPlayer.setReceiverVolume(false, vol / 100);
|
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 () {
|
self.getPlayerState = function () {
|
||||||
|
|
||||||
var deferred = $.Deferred();
|
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 () {
|
self.pause = function () {
|
||||||
|
|
||||||
currentMediaElement.pause();
|
currentMediaElement.pause();
|
||||||
|
@ -998,7 +1041,7 @@
|
||||||
|
|
||||||
state.NowPlayingItem = state.NowPlayingItem || {};
|
state.NowPlayingItem = state.NowPlayingItem || {};
|
||||||
var nowPlayingItem = state.NowPlayingItem;
|
var nowPlayingItem = state.NowPlayingItem;
|
||||||
|
|
||||||
nowPlayingItem.Id = item.Id;
|
nowPlayingItem.Id = item.Id;
|
||||||
nowPlayingItem.MediaType = item.MediaType;
|
nowPlayingItem.MediaType = item.MediaType;
|
||||||
nowPlayingItem.Type = item.Type;
|
nowPlayingItem.Type = item.Type;
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
$('.btnCommand', page).on('click', function () {
|
$('.btnCommand', page).on('click', function () {
|
||||||
|
|
||||||
|
currentPlayer.sendCommand({
|
||||||
|
Name: this.getAttribute('data-command')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +97,7 @@
|
||||||
|
|
||||||
var page = this;
|
var page = this;
|
||||||
|
|
||||||
|
$('.radioTabButton', page).checked(false).checkboxradio('refresh');
|
||||||
$('.radioTabButton:first', page).checked(true).checkboxradio('refresh').trigger('change');
|
$('.radioTabButton:first', page).checked(true).checkboxradio('refresh').trigger('change');
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
|
@ -28,19 +28,32 @@
|
||||||
ApiClient.sendPlayStateCommand(sessionId, command, options);
|
ApiClient.sendPlayStateCommand(sessionId, command, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendCommand(command, options) {
|
|
||||||
|
|
||||||
var sessionId = MediaController.getPlayerInfo().id;
|
|
||||||
|
|
||||||
ApiClient.sendCommand(sessionId, command, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
function remoteControlPlayer() {
|
function remoteControlPlayer() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.name = 'Remote Control';
|
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) {
|
self.play = function (options) {
|
||||||
|
|
||||||
sendPlayCommand(options, 'PlayNow');
|
sendPlayCommand(options, 'PlayNow');
|
||||||
|
@ -99,19 +112,19 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
self.mute = function () {
|
self.mute = function () {
|
||||||
sendCommand('Mute');
|
sendCommandByName('Mute');
|
||||||
};
|
};
|
||||||
|
|
||||||
self.unMute = function () {
|
self.unMute = function () {
|
||||||
sendCommand('Unmute');
|
sendCommandByName('Unmute');
|
||||||
};
|
};
|
||||||
|
|
||||||
self.toggleMute = function () {
|
self.toggleMute = function () {
|
||||||
sendCommand('ToggleMute');
|
sendCommandByName('ToggleMute');
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setVolume = function (vol) {
|
self.setVolume = function (vol) {
|
||||||
sendCommand('SetVolume', {
|
sendCommandByName('SetVolume', {
|
||||||
|
|
||||||
Volume: vol
|
Volume: vol
|
||||||
|
|
||||||
|
@ -120,7 +133,7 @@
|
||||||
|
|
||||||
self.displayContent = function (options) {
|
self.displayContent = function (options) {
|
||||||
|
|
||||||
sendCommand('DisplayContent', {
|
sendCommandByName('DisplayContent', {
|
||||||
|
|
||||||
ItemName: options.itemName,
|
ItemName: options.itemName,
|
||||||
ItemType: options.itemType,
|
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) {
|
onWebSocketMessageReceived: function (e, data) {
|
||||||
|
|
||||||
var msg = data;
|
var msg = data;
|
||||||
|
@ -911,15 +933,7 @@ var Dashboard = {
|
||||||
|
|
||||||
var cmd = msg.Data;
|
var cmd = msg.Data;
|
||||||
|
|
||||||
if (cmd.Name === 'GoHome') {
|
Dashboard.processGeneralCommand(cmd);
|
||||||
Dashboard.navigate('index.html');
|
|
||||||
}
|
|
||||||
else if (cmd.Name === 'GoToSettings') {
|
|
||||||
Dashboard.navigate('dashboard.html');
|
|
||||||
}
|
|
||||||
else if (cmd.Name === 'DisplayContent') {
|
|
||||||
Dashboard.onBrowseCommand(cmd.Arguments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (msg.MessageType === "MessageCommand") {
|
else if (msg.MessageType === "MessageCommand") {
|
||||||
|
|
||||||
|
@ -1283,7 +1297,8 @@ var Dashboard = {
|
||||||
"ToggleFullscreen",
|
"ToggleFullscreen",
|
||||||
"SetAudioStreamIndex",
|
"SetAudioStreamIndex",
|
||||||
"SetSubtitleStreamIndex",
|
"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) {
|
if (!sessionId) {
|
||||||
throw new Error("null sessionId");
|
throw new Error("null sessionId");
|
||||||
|
@ -3074,12 +3074,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
||||||
url: url
|
url: url
|
||||||
};
|
};
|
||||||
|
|
||||||
options = {
|
ajaxOptions.data = JSON.stringify(command);
|
||||||
Arguments: options || {},
|
|
||||||
Name: command
|
|
||||||
};
|
|
||||||
|
|
||||||
ajaxOptions.data = JSON.stringify(options);
|
|
||||||
ajaxOptions.contentType = "application/json";
|
ajaxOptions.contentType = "application/json";
|
||||||
|
|
||||||
return self.ajax(ajaxOptions);
|
return self.ajax(ajaxOptions);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue