mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fixed subtitle downloading
This commit is contained in:
parent
2af68415eb
commit
b39a9e4797
5 changed files with 219 additions and 21 deletions
|
@ -39,7 +39,7 @@
|
||||||
<div data-role="controlgroup" data-type="horizontal">
|
<div data-role="controlgroup" data-type="horizontal">
|
||||||
<button data-icon="volume-up" data-inline="true" data-iconpos="notext" title="${ButtonVolumeUp}" class="btnCommand" data-command="VolumeUp">${ButtonVolumeUp}</button>
|
<button data-icon="volume-up" data-inline="true" data-iconpos="notext" title="${ButtonVolumeUp}" class="btnCommand" data-command="VolumeUp">${ButtonVolumeUp}</button>
|
||||||
<button data-icon="volume-off" data-inline="true" data-iconpos="notext" title="${ButtonMute}" class="btnCommand" data-command="ToggleMute">${ButtonMute}</button>
|
<button data-icon="volume-off" data-inline="true" data-iconpos="notext" title="${ButtonMute}" class="btnCommand" data-command="ToggleMute">${ButtonMute}</button>
|
||||||
<button data-icon="expand" data-inline="true" data-iconpos="notext" title="${ButtonFullscreen}" class="btnToggleFullscreen btnPlayStateCommand" data-command="ToggleFullscreen" style="visibility:hidden;">${ButtonFullscreen}</button>
|
<button data-icon="expand" data-inline="true" data-iconpos="notext" title="${ButtonFullscreen}" class="btnToggleFullscreen btnPlayStateCommand" data-command="ToggleFullscreen" style="visibility: hidden;">${ButtonFullscreen}</button>
|
||||||
<button data-icon="expand" data-inline="true" data-iconpos="notext" title="${ButtonFullscreen}" class="btnToggleFullscreen videoButton btnPlayStateCommand" data-command="ToggleFullscreen">${ButtonFullscreen}</button>
|
<button data-icon="expand" data-inline="true" data-iconpos="notext" title="${ButtonFullscreen}" class="btnToggleFullscreen videoButton btnPlayStateCommand" data-command="ToggleFullscreen">${ButtonFullscreen}</button>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="controlgroup" data-type="horizontal">
|
<div data-role="controlgroup" data-type="horizontal">
|
||||||
|
@ -85,6 +85,25 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-role="popup" id="popupAudioTrackMenu" data-history="false" data-transition="flip">
|
||||||
|
<ul data-role="listview" data-inset="true" style="min-width: 210px;">
|
||||||
|
<li data-role="list-divider">Select Audio</li>
|
||||||
|
<li><a href="#">View details</a></li>
|
||||||
|
<li><a href="#">Edit</a></li>
|
||||||
|
<li><a href="#">Disable</a></li>
|
||||||
|
<li><a href="#">Delete</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-role="popup" id="popupSubtitleTrackMenu" data-history="false" data-transition="flip">
|
||||||
|
<ul data-role="listview" data-inset="true" style="min-width: 210px;">
|
||||||
|
<li data-role="list-divider">Select Subtitles</li>
|
||||||
|
<li><a href="#">View details</a></li>
|
||||||
|
<li><a href="#">Edit</a></li>
|
||||||
|
<li><a href="#">Disable</a></li>
|
||||||
|
<li><a href="#">Delete</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -319,8 +319,10 @@
|
||||||
player.setVolume(cmd.Arguments.Volume);
|
player.setVolume(cmd.Arguments.Volume);
|
||||||
break;
|
break;
|
||||||
case 'SetAudioStreamIndex':
|
case 'SetAudioStreamIndex':
|
||||||
|
player.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
|
||||||
break;
|
break;
|
||||||
case 'SetSubtitleStreamIndex':
|
case 'SetSubtitleStreamIndex':
|
||||||
|
player.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
|
||||||
break;
|
break;
|
||||||
case 'ToggleFullscreen':
|
case 'ToggleFullscreen':
|
||||||
player.toggleFullscreen();
|
player.toggleFullscreen();
|
||||||
|
|
|
@ -147,6 +147,14 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.setAudioStreamIndex = function (index) {
|
||||||
|
self.changeStream(self.getCurrentTicks(), { AudioStreamIndex: index });
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setSubtitleStreamIndex = function (index) {
|
||||||
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
||||||
|
};
|
||||||
|
|
||||||
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function (e) {
|
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function (e) {
|
||||||
|
|
||||||
var videoControls = $('#videoControls');
|
var videoControls = $('#videoControls');
|
||||||
|
@ -209,7 +217,7 @@
|
||||||
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
||||||
var index = parseInt(this.getAttribute('data-index'));
|
var index = parseInt(this.getAttribute('data-index'));
|
||||||
|
|
||||||
self.changeStream(self.getCurrentTicks(), { AudioStreamIndex: index });
|
self.setAudioStreamIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
hideFlyout($('#video-audioTracksFlyout'));
|
hideFlyout($('#video-audioTracksFlyout'));
|
||||||
|
@ -220,7 +228,7 @@
|
||||||
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
||||||
var index = parseInt(this.getAttribute('data-index'));
|
var index = parseInt(this.getAttribute('data-index'));
|
||||||
|
|
||||||
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
self.setSubtitleStreamIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
hideFlyout($('#video-subtitleFlyout'));
|
hideFlyout($('#video-subtitleFlyout'));
|
||||||
|
|
|
@ -4,6 +4,102 @@
|
||||||
var lastPlayerState;
|
var lastPlayerState;
|
||||||
var isPositionSliderActive;
|
var isPositionSliderActive;
|
||||||
|
|
||||||
|
function showAudioMenu(page, item) {
|
||||||
|
|
||||||
|
var streams = (item.MediaStreams || []).filter(function (i) {
|
||||||
|
|
||||||
|
return i.Type == 'Audio';
|
||||||
|
});
|
||||||
|
|
||||||
|
var elem = $('#popupAudioTrackMenu', page);
|
||||||
|
|
||||||
|
var html = '<li data-role="list-divider">Select Audio</li>';
|
||||||
|
|
||||||
|
html += streams.map(function (s) {
|
||||||
|
|
||||||
|
var streamHtml = '<li><a data-index="' + s.Index + '" href="#" style="font-size:13px;" class="lnkTrackOption">';
|
||||||
|
|
||||||
|
streamHtml += (s.Codec || '').toUpperCase();
|
||||||
|
|
||||||
|
if (s.Profile) {
|
||||||
|
streamHtml += ' ' + s.Profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
streamHtml += '<br/>';
|
||||||
|
|
||||||
|
var extras = [];
|
||||||
|
|
||||||
|
if (s.Language) {
|
||||||
|
extras.push(s.Language);
|
||||||
|
}
|
||||||
|
if (s.Layout) {
|
||||||
|
extras.push(s.Layout);
|
||||||
|
}
|
||||||
|
else if (s.Channels) {
|
||||||
|
extras.push(s.Channels + ' ch');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.BitRate) {
|
||||||
|
extras.push((parseInt(s.BitRate / 1000)) + ' kbps');
|
||||||
|
}
|
||||||
|
|
||||||
|
streamHtml += extras.join(' - ');
|
||||||
|
|
||||||
|
streamHtml += '</a></li>';
|
||||||
|
|
||||||
|
return streamHtml;
|
||||||
|
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
$('ul', elem).html(html).listview('refresh').trigger('create');
|
||||||
|
|
||||||
|
elem.popup('open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSubtitleMenu(page, item) {
|
||||||
|
|
||||||
|
var streams = (item.MediaStreams || []).filter(function (i) {
|
||||||
|
|
||||||
|
return i.Type == 'Subtitle';
|
||||||
|
});
|
||||||
|
|
||||||
|
var elem = $('#popupSubtitleTrackMenu', page);
|
||||||
|
|
||||||
|
var html = '<li data-role="list-divider">Select Subtitles</li>';
|
||||||
|
|
||||||
|
html += '<li><a href="#" style="font-size:13px;" data-index="-1" class="lnkTrackOption">Off</a></li>';
|
||||||
|
|
||||||
|
html += streams.map(function (s) {
|
||||||
|
|
||||||
|
var streamHtml = '<li><a data-index="' + s.Index + '" href="#" style="font-size:13px;" class="lnkTrackOption">';
|
||||||
|
|
||||||
|
streamHtml += (s.Language || 'Unknown language');
|
||||||
|
|
||||||
|
if (s.IsDefault && s.IsForced) {
|
||||||
|
streamHtml += ' (Default/Forced)';
|
||||||
|
}
|
||||||
|
else if (s.IsDefault) {
|
||||||
|
streamHtml += ' (Default)';
|
||||||
|
}
|
||||||
|
else if (s.IsForced) {
|
||||||
|
streamHtml += ' (Forced)';
|
||||||
|
}
|
||||||
|
|
||||||
|
streamHtml += '<br/>';
|
||||||
|
|
||||||
|
streamHtml += (s.Codec || '').toUpperCase();
|
||||||
|
|
||||||
|
streamHtml += '</a></li>';
|
||||||
|
|
||||||
|
return streamHtml;
|
||||||
|
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
$('ul', elem).html(html).listview('refresh').trigger('create');
|
||||||
|
|
||||||
|
elem.popup('open');
|
||||||
|
}
|
||||||
|
|
||||||
function bindEvents(page) {
|
function bindEvents(page) {
|
||||||
|
|
||||||
$('.radioTabButton', page).on('change', function () {
|
$('.radioTabButton', page).on('change', function () {
|
||||||
|
@ -16,35 +112,90 @@
|
||||||
|
|
||||||
$('.btnCommand,.btnToggleFullscreen', page).on('click', function () {
|
$('.btnCommand,.btnToggleFullscreen', page).on('click', function () {
|
||||||
|
|
||||||
MediaController.sendCommand({
|
if (currentPlayer) {
|
||||||
Name: this.getAttribute('data-command')
|
MediaController.sendCommand({
|
||||||
|
Name: this.getAttribute('data-command')
|
||||||
}, currentPlayer);
|
|
||||||
|
}, currentPlayer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#popupAudioTrackMenu', page).on('click', '.lnkTrackOption', function () {
|
||||||
|
|
||||||
|
if (currentPlayer && lastPlayerState) {
|
||||||
|
|
||||||
|
var index = this.getAttribute('data-index');
|
||||||
|
|
||||||
|
currentPlayer.setAudioStreamIndex(parseInt(index));
|
||||||
|
|
||||||
|
$('#popupAudioTrackMenu', page).popup('close');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#popupSubtitleTrackMenu', page).on('click', '.lnkTrackOption', function () {
|
||||||
|
|
||||||
|
if (currentPlayer && lastPlayerState) {
|
||||||
|
var index = this.getAttribute('data-index');
|
||||||
|
|
||||||
|
currentPlayer.setSubtitleStreamIndex(parseInt(index));
|
||||||
|
|
||||||
|
$('#popupSubtitleTrackMenu', page).popup('close');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btnAudioTracks', page).on('click', function () {
|
||||||
|
|
||||||
|
if (currentPlayer && lastPlayerState) {
|
||||||
|
showAudioMenu(page, lastPlayerState.NowPlayingItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btnSubtitles', page).on('click', function () {
|
||||||
|
|
||||||
|
if (currentPlayer && lastPlayerState) {
|
||||||
|
showSubtitleMenu(page, lastPlayerState.NowPlayingItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btnChapters', page).on('click', function () {
|
||||||
|
|
||||||
|
if (currentPlayer && lastPlayerState) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnStop', page).on('click', function () {
|
$('.btnStop', page).on('click', function () {
|
||||||
|
|
||||||
currentPlayer.stop();
|
if (currentPlayer) {
|
||||||
|
currentPlayer.stop();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnPlay', page).on('click', function () {
|
$('.btnPlay', page).on('click', function () {
|
||||||
|
|
||||||
currentPlayer.unpause();
|
if (currentPlayer) {
|
||||||
|
currentPlayer.unpause();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnPause', page).on('click', function () {
|
$('.btnPause', page).on('click', function () {
|
||||||
|
|
||||||
currentPlayer.pause();
|
if (currentPlayer) {
|
||||||
|
currentPlayer.pause();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnNextTrack', page).on('click', function () {
|
$('.btnNextTrack', page).on('click', function () {
|
||||||
|
|
||||||
currentPlayer.nextTrack();
|
if (currentPlayer) {
|
||||||
|
currentPlayer.nextTrack();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnPreviousTrack', page).on('click', function () {
|
$('.btnPreviousTrack', page).on('click', function () {
|
||||||
|
|
||||||
currentPlayer.previousTrack();
|
if (currentPlayer) {
|
||||||
|
currentPlayer.previousTrack();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.positionSlider', page).on('slidestart', function () {
|
$('.positionSlider', page).on('slidestart', function () {
|
||||||
|
@ -96,6 +247,12 @@
|
||||||
button.addClass('hide');
|
button.addClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasStreams(item, type) {
|
||||||
|
return item && item.MediaStreams && item.MediaStreams.filter(function (i) {
|
||||||
|
return i.Type == type;
|
||||||
|
}).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
function updatePlayerState(page, state) {
|
function updatePlayerState(page, state) {
|
||||||
|
|
||||||
lastPlayerState = state;
|
lastPlayerState = state;
|
||||||
|
@ -108,17 +265,17 @@
|
||||||
|
|
||||||
$('.btnToggleFullscreen', page).buttonEnabled(item && item.MediaType == 'Video' && supportedCommands.indexOf('ToggleFullscreen') != -1);
|
$('.btnToggleFullscreen', page).buttonEnabled(item && item.MediaType == 'Video' && supportedCommands.indexOf('ToggleFullscreen') != -1);
|
||||||
|
|
||||||
$('.btnAudioTracks', page).buttonEnabled(false);
|
$('.btnAudioTracks', page).buttonEnabled(hasStreams(item, 'Audio') && supportedCommands.indexOf('SetAudioStreamIndex') != -1);
|
||||||
$('.btnSubtitles', page).buttonEnabled(false);
|
$('.btnSubtitles', page).buttonEnabled(hasStreams(item, 'Subtitle') && supportedCommands.indexOf('SetSubtitleStreamIndex') != -1);
|
||||||
$('.btnChapters', page).buttonEnabled(false);
|
$('.btnChapters', page).buttonEnabled(item && item.Chapters && item.Chapters.length);
|
||||||
|
|
||||||
$('.btnStop', page).buttonEnabled(item != null);
|
$('.btnStop', page).buttonEnabled(item != null);
|
||||||
$('.btnNextTrack', page).buttonEnabled(item != null);
|
$('.btnNextTrack', page).buttonEnabled(item != null);
|
||||||
$('.btnPreviousTrack', page).buttonEnabled(item != null);
|
$('.btnPreviousTrack', page).buttonEnabled(item != null);
|
||||||
|
|
||||||
var btnPause = $('.btnPause', page).buttonEnabled(item != null);
|
var btnPause = $('.btnPause', page).buttonEnabled(item != null);
|
||||||
var btnPlay = $('.btnPlay', page).buttonEnabled(item != null);
|
var btnPlay = $('.btnPlay', page).buttonEnabled(item != null);
|
||||||
|
|
||||||
var playState = state.PlayState || {};
|
var playState = state.PlayState || {};
|
||||||
|
|
||||||
if (playState.IsPaused) {
|
if (playState.IsPaused) {
|
||||||
|
@ -147,7 +304,7 @@
|
||||||
|
|
||||||
positionSlider.val(0);
|
positionSlider.val(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playState.CanSeek) {
|
if (playState.CanSeek) {
|
||||||
positionSlider.slider("enable");
|
positionSlider.slider("enable");
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,7 +331,7 @@
|
||||||
} else {
|
} else {
|
||||||
$('.videoButton', page).css('visibility', 'hidden');
|
$('.videoButton', page).css('visibility', 'hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNowPlayingInfo(page, state);
|
updateNowPlayingInfo(page, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +378,7 @@
|
||||||
|
|
||||||
setImageUrl(page, url);
|
setImageUrl(page, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImageUrl(page, url) {
|
function setImageUrl(page, url) {
|
||||||
currentImgUrl = url;
|
currentImgUrl = url;
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,18 @@
|
||||||
sendCommandByName('ToggleFullscreen');
|
sendCommandByName('ToggleFullscreen');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.setAudioStreamIndex = function (index) {
|
||||||
|
sendCommandByName('SetAudioStreamIndex', {
|
||||||
|
Index: index
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setSubtitleStreamIndex = function (index) {
|
||||||
|
sendCommandByName('SetSubtitleStreamIndex', {
|
||||||
|
Index: index
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
self.displayContent = function (options) {
|
self.displayContent = function (options) {
|
||||||
|
|
||||||
sendCommandByName('DisplayContent', {
|
sendCommandByName('DisplayContent', {
|
||||||
|
@ -276,7 +288,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWebSocketConnectionChange() {
|
function onWebSocketConnectionChange() {
|
||||||
|
|
||||||
// Reconnect
|
// Reconnect
|
||||||
if (player.isUpdating) {
|
if (player.isUpdating) {
|
||||||
player.subscribeToPlayerUpdates();
|
player.subscribeToPlayerUpdates();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue