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
|
@ -85,6 +85,25 @@
|
|||
</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>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -319,8 +319,10 @@
|
|||
player.setVolume(cmd.Arguments.Volume);
|
||||
break;
|
||||
case 'SetAudioStreamIndex':
|
||||
player.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case 'SetSubtitleStreamIndex':
|
||||
player.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case '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) {
|
||||
|
||||
var videoControls = $('#videoControls');
|
||||
|
@ -209,7 +217,7 @@
|
|||
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
||||
var index = parseInt(this.getAttribute('data-index'));
|
||||
|
||||
self.changeStream(self.getCurrentTicks(), { AudioStreamIndex: index });
|
||||
self.setAudioStreamIndex(index);
|
||||
}
|
||||
|
||||
hideFlyout($('#video-audioTracksFlyout'));
|
||||
|
@ -220,7 +228,7 @@
|
|||
if (!$(this).hasClass('selectedMediaFlyoutOption')) {
|
||||
var index = parseInt(this.getAttribute('data-index'));
|
||||
|
||||
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
||||
self.setSubtitleStreamIndex(index);
|
||||
}
|
||||
|
||||
hideFlyout($('#video-subtitleFlyout'));
|
||||
|
|
|
@ -4,6 +4,102 @@
|
|||
var lastPlayerState;
|
||||
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) {
|
||||
|
||||
$('.radioTabButton', page).on('change', function () {
|
||||
|
@ -16,35 +112,90 @@
|
|||
|
||||
$('.btnCommand,.btnToggleFullscreen', page).on('click', function () {
|
||||
|
||||
if (currentPlayer) {
|
||||
MediaController.sendCommand({
|
||||
Name: this.getAttribute('data-command')
|
||||
|
||||
}, 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 () {
|
||||
|
||||
if (currentPlayer) {
|
||||
currentPlayer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
$('.btnPlay', page).on('click', function () {
|
||||
|
||||
if (currentPlayer) {
|
||||
currentPlayer.unpause();
|
||||
}
|
||||
});
|
||||
|
||||
$('.btnPause', page).on('click', function () {
|
||||
|
||||
if (currentPlayer) {
|
||||
currentPlayer.pause();
|
||||
}
|
||||
});
|
||||
|
||||
$('.btnNextTrack', page).on('click', function () {
|
||||
|
||||
if (currentPlayer) {
|
||||
currentPlayer.nextTrack();
|
||||
}
|
||||
});
|
||||
|
||||
$('.btnPreviousTrack', page).on('click', function () {
|
||||
|
||||
if (currentPlayer) {
|
||||
currentPlayer.previousTrack();
|
||||
}
|
||||
});
|
||||
|
||||
$('.positionSlider', page).on('slidestart', function () {
|
||||
|
@ -96,6 +247,12 @@
|
|||
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) {
|
||||
|
||||
lastPlayerState = state;
|
||||
|
@ -108,9 +265,9 @@
|
|||
|
||||
$('.btnToggleFullscreen', page).buttonEnabled(item && item.MediaType == 'Video' && supportedCommands.indexOf('ToggleFullscreen') != -1);
|
||||
|
||||
$('.btnAudioTracks', page).buttonEnabled(false);
|
||||
$('.btnSubtitles', page).buttonEnabled(false);
|
||||
$('.btnChapters', page).buttonEnabled(false);
|
||||
$('.btnAudioTracks', page).buttonEnabled(hasStreams(item, 'Audio') && supportedCommands.indexOf('SetAudioStreamIndex') != -1);
|
||||
$('.btnSubtitles', page).buttonEnabled(hasStreams(item, 'Subtitle') && supportedCommands.indexOf('SetSubtitleStreamIndex') != -1);
|
||||
$('.btnChapters', page).buttonEnabled(item && item.Chapters && item.Chapters.length);
|
||||
|
||||
$('.btnStop', page).buttonEnabled(item != null);
|
||||
$('.btnNextTrack', page).buttonEnabled(item != null);
|
||||
|
|
|
@ -143,6 +143,18 @@
|
|||
sendCommandByName('ToggleFullscreen');
|
||||
};
|
||||
|
||||
self.setAudioStreamIndex = function (index) {
|
||||
sendCommandByName('SetAudioStreamIndex', {
|
||||
Index: index
|
||||
});
|
||||
};
|
||||
|
||||
self.setSubtitleStreamIndex = function (index) {
|
||||
sendCommandByName('SetSubtitleStreamIndex', {
|
||||
Index: index
|
||||
});
|
||||
};
|
||||
|
||||
self.displayContent = function (options) {
|
||||
|
||||
sendCommandByName('DisplayContent', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue