mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
chapter downloading fixes
This commit is contained in:
parent
f977419f95
commit
462766c0db
2 changed files with 94 additions and 16 deletions
|
@ -36,6 +36,16 @@
|
|||
return video;
|
||||
};
|
||||
|
||||
self.getCurrentSubtitleStream = function () {
|
||||
return self.getSubtitleStream(self.currentSubtitleStreamIndex);
|
||||
};
|
||||
|
||||
self.getSubtitleStream = function (index) {
|
||||
return self.currentMediaSource.MediaStreams.filter(function (s) {
|
||||
return s.Type == 'Subtitle' && s.Index == index;
|
||||
})[0];
|
||||
};
|
||||
|
||||
self.remoteFullscreen = function () {
|
||||
|
||||
var videoControls = $("#videoControls");
|
||||
|
@ -151,7 +161,62 @@
|
|||
};
|
||||
|
||||
self.setSubtitleStreamIndex = function (index) {
|
||||
|
||||
if (!self.supportsTextTracks()) {
|
||||
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
||||
self.currentSubtitleStreamIndex = index;
|
||||
return;
|
||||
}
|
||||
|
||||
var currentStream = self.getCurrentSubtitleStream();
|
||||
|
||||
var newStream = self.getSubtitleStream(index);
|
||||
|
||||
if (!currentStream && !newStream) return;
|
||||
|
||||
var selectedTrackElementIndex = -1;
|
||||
|
||||
if (currentStream && !newStream) {
|
||||
|
||||
if (!currentStream.IsTextSubtitleStream) {
|
||||
|
||||
// Need to change the transcoded stream to remove subs
|
||||
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: -1 });
|
||||
}
|
||||
}
|
||||
else if (!currentStream && newStream) {
|
||||
|
||||
if (newStream.IsTextSubtitleStream) {
|
||||
selectedTrackElementIndex = index;
|
||||
} else {
|
||||
|
||||
// Need to change the transcoded stream to add subs
|
||||
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
||||
}
|
||||
}
|
||||
|
||||
self.setCurrentTrackElement(selectedTrackElementIndex);
|
||||
self.currentSubtitleStreamIndex = index;
|
||||
};
|
||||
|
||||
self.setCurrentTrackElement = function (index) {
|
||||
|
||||
var textStreams = self.currentMediaSource.MediaStreams.filter(function (s) {
|
||||
return s.Type == 'Subtitle' && s.IsTextSubtitleStream;
|
||||
});
|
||||
|
||||
var allTracks = video.textTracks; // get list of tracks
|
||||
|
||||
for (var i = 0; i < allTracks.length; i++) {
|
||||
|
||||
var trackIndex = textStreams[i].Index;
|
||||
|
||||
if (trackIndex == index) {
|
||||
allTracks[i].mode = "showing"; // show this track
|
||||
} else {
|
||||
allTracks[i].mode = "disabled"; // hide all other tracks
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function (e) {
|
||||
|
@ -532,7 +597,7 @@
|
|||
return currentStream.Type == "Subtitle";
|
||||
});
|
||||
|
||||
var currentIndex = self.currentSubtitleStreamIndex;
|
||||
var currentIndex = self.currentSubtitleStreamIndex || -1;
|
||||
|
||||
var html = '';
|
||||
|
||||
|
@ -742,7 +807,7 @@
|
|||
mediaSourceId: mediaSource.Id
|
||||
};
|
||||
|
||||
if (selectedSubtitleStream && !selectedSubtitleStream.IsTextSubtitleStream) {
|
||||
if (selectedSubtitleStream && (!selectedSubtitleStream.IsTextSubtitleStream || !self.supportsTextTracks())) {
|
||||
baseParams.SubtitleStreamIndex = mediaSource.DefaultSubtitleStreamIndex;
|
||||
}
|
||||
|
||||
|
@ -842,6 +907,7 @@
|
|||
|
||||
html += '<source type="video/mp4" src="' + mp4VideoUrl + '" />';
|
||||
|
||||
if (self.supportsTextTracks()) {
|
||||
var textStreams = subtitleStreams.filter(function (s) {
|
||||
return s.IsTextSubtitleStream;
|
||||
});
|
||||
|
@ -854,7 +920,8 @@
|
|||
|
||||
var defaultAttribute = i.Index == mediaSource.DefaultSubtitleStreamIndex ? ' default' : '';
|
||||
|
||||
html += '<track data-index="' + textStream.Index + '" kind="subtitles" src="' + textStreamUrl + '" srclang="' + (textStream.Language || 'und') + '"' + defaultAttribute + '>';
|
||||
html += '<track kind="subtitles" src="' + textStreamUrl + '" srclang="' + (textStream.Language || 'und') + '"' + defaultAttribute + '>';
|
||||
}
|
||||
}
|
||||
|
||||
html += '</video>';
|
||||
|
|
|
@ -218,6 +218,17 @@
|
|||
$(self).trigger('positionchange', [state]);
|
||||
};
|
||||
|
||||
self.supportsTextTracks = function () {
|
||||
|
||||
// Does not support changing tracks via mode property
|
||||
if ($.browser.mozilla) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For now, until perfected
|
||||
return false;
|
||||
};
|
||||
|
||||
self.canPlayVideoDirect = function (mediaSource, videoStream, audioStream, subtitleStream, maxWidth, bitrate) {
|
||||
|
||||
if (!mediaSource) {
|
||||
|
@ -243,7 +254,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if (subtitleStream && subtitleStream.IsGraphicalSubtitleStream) {
|
||||
if (subtitleStream && (subtitleStream.IsGraphicalSubtitleStream || !self.supportsTextTracks())) {
|
||||
console.log('Transcoding because subtitles are required');
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue