mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
modularize media player
This commit is contained in:
parent
db61c30557
commit
440bfc832a
3 changed files with 353 additions and 159 deletions
|
@ -271,7 +271,7 @@
|
|||
|
||||
var mediaControls = $("#videoPlayer");
|
||||
|
||||
var state = self.getPlayerStateInternal(self.currentMediaElement, item, self.currentMediaSource);
|
||||
var state = self.getPlayerStateInternal(self.currentMediaRenderer, item, self.currentMediaSource);
|
||||
|
||||
var url = "";
|
||||
var imageWidth = 400;
|
||||
|
@ -751,7 +751,7 @@
|
|||
return currentStream.Type == "Audio";
|
||||
});
|
||||
|
||||
var currentIndex = getParameterByName('AudioStreamIndex', self.getCurrentSrc(self.currentMediaElement));
|
||||
var currentIndex = getParameterByName('AudioStreamIndex', self.getCurrentSrc(self.currentMediaRenderer));
|
||||
|
||||
var html = '';
|
||||
html += '<div class="videoPlayerPopupContent">';
|
||||
|
@ -917,7 +917,7 @@
|
|||
|
||||
function getQualityFlyoutHtml() {
|
||||
|
||||
var currentSrc = self.getCurrentSrc(self.currentMediaElement).toLowerCase();
|
||||
var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase();
|
||||
var isStatic = currentSrc.indexOf('static=true') != -1;
|
||||
|
||||
var videoStream = self.currentMediaSource.MediaStreams.filter(function (stream) {
|
||||
|
@ -1042,13 +1042,11 @@
|
|||
};
|
||||
|
||||
// Replace audio version
|
||||
self.cleanup = function (playerElement) {
|
||||
self.cleanup = function (mediaRenderer) {
|
||||
|
||||
if (playerElement.tagName.toLowerCase() == 'video') {
|
||||
currentTimeElement.html('--:--');
|
||||
currentTimeElement.html('--:--');
|
||||
|
||||
unbindEventsForPlayback();
|
||||
}
|
||||
unbindEventsForPlayback();
|
||||
};
|
||||
|
||||
self.playVideo = function (item, mediaSource, startPosition) {
|
||||
|
@ -1189,41 +1187,18 @@
|
|||
videoControls.removeClass('hide');
|
||||
}
|
||||
|
||||
var video = $("video", videoElement);
|
||||
var mediaRenderer = new HtmlMediaRenderer('video');
|
||||
|
||||
initialVolume = self.getSavedVolume();
|
||||
|
||||
video.each(function () {
|
||||
this.volume = initialVolume;
|
||||
});
|
||||
mediaRenderer.volume(initialVolume);
|
||||
|
||||
volumeSlider.val(initialVolume).slider('refresh');
|
||||
updateVolumeButtons(initialVolume);
|
||||
|
||||
video.one("loadedmetadata.mediaplayerevent", function (e) {
|
||||
$(mediaRenderer).on("volumechange.mediaplayerevent", function (e) {
|
||||
|
||||
// The IE video player won't autoplay without this
|
||||
if ($.browser.msie) {
|
||||
this.play();
|
||||
}
|
||||
|
||||
}).one("playing.mediaplayerevent", function (e) {
|
||||
|
||||
// TODO: This is not working in chrome. Is it too early?
|
||||
|
||||
// Appending #t=xxx to the query string doesn't seem to work with HLS
|
||||
if (startPositionInSeekParam && this.currentSrc && this.currentSrc.toLowerCase().indexOf('.m3u8') != -1) {
|
||||
var element = this;
|
||||
setTimeout(function () {
|
||||
element.currentTime = startPositionInSeekParam;
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}).on("volumechange.mediaplayerevent", function (e) {
|
||||
|
||||
var vol = this.volume;
|
||||
|
||||
updateVolumeButtons(vol);
|
||||
updateVolumeButtons(this.volume());
|
||||
|
||||
}).one("playing.mediaplayerevent", function () {
|
||||
|
||||
|
@ -1262,9 +1237,6 @@
|
|||
|
||||
self.stop();
|
||||
|
||||
var errorCode = this.error ? this.error.code : '';
|
||||
console.log('Html5 Video error code: ' + errorCode);
|
||||
|
||||
var errorMsg = Globalize.translate('MessageErrorPlayingVideo');
|
||||
|
||||
if (item.Type == "TvChannel") {
|
||||
|
@ -1289,7 +1261,7 @@
|
|||
}).on("click.mediaplayerevent", function (e) {
|
||||
|
||||
if (!$.browser.mobile) {
|
||||
if (this.paused) {
|
||||
if (this.paused()) {
|
||||
self.unpause();
|
||||
} else {
|
||||
self.pause();
|
||||
|
@ -1311,7 +1283,7 @@
|
|||
|
||||
$('body').addClass('bodyWithPopupOpen');
|
||||
|
||||
self.currentMediaElement = video[0];
|
||||
self.currentMediaRenderer = mediaRenderer;
|
||||
self.currentDurationTicks = self.currentMediaSource.RunTimeTicks;
|
||||
|
||||
self.updateNowPlayingInfo(item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue