1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update timeshifting

This commit is contained in:
Luke Pulverenti 2016-09-18 16:38:38 -04:00
parent 2efdf1fcd5
commit ef9ab82058
3 changed files with 48 additions and 34 deletions

View file

@ -269,7 +269,7 @@ define(['browser'], function (browser) {
} }
var mp3Added = false; var mp3Added = false;
if (canPlayMkv || canPlayTs) { if ((canPlayMkv && options.enableMkvProgressive !== false) || (canPlayTs && options.enableMkvProgressive !== false)) {
if (supportsMp3VideoAudio) { if (supportsMp3VideoAudio) {
mp3Added = true; mp3Added = true;
videoAudioCodecs.push('mp3'); videoAudioCodecs.push('mp3');
@ -421,7 +421,8 @@ define(['browser'], function (browser) {
AudioCodec: hlsVideoAudioCodecs.join(','), AudioCodec: hlsVideoAudioCodecs.join(','),
VideoCodec: 'h264', VideoCodec: 'h264',
Context: 'Streaming', Context: 'Streaming',
Protocol: 'hls' Protocol: 'hls',
MaxAudioChannels: physicalAudioChannels.toString()
}); });
} }

View file

@ -170,7 +170,7 @@
return elem; return elem;
} }
function enableHlsPlayer(src) { function enableHlsPlayer(src, item, mediaSource) {
if (src) { if (src) {
if (src.indexOf('.m3u8') == -1) { if (src.indexOf('.m3u8') == -1) {
@ -178,7 +178,25 @@
} }
} }
return MediaPlayer.canPlayHls() && !MediaPlayer.canPlayNativeHls(); if (MediaPlayer.canPlayHls()) {
if (window.MediaSource == null) {
return false;
}
if (MediaPlayer.canPlayNativeHls() && mediaSource.RunTimeTicks) {
return false;
}
// For now don't do this in edge because we lose some native audio support
if (browser.edge) {
return false;
}
return true;
}
return false;
} }
function getCrossOriginValue(mediaSource) { function getCrossOriginValue(mediaSource) {
@ -384,10 +402,11 @@
} }
subtitleTrackIndexToSetOnPlaying = currentTrackIndex; subtitleTrackIndexToSetOnPlaying = currentTrackIndex;
if (enableHlsPlayer(val)) { if (enableHlsPlayer(val, item, mediaSource)) {
setTracks(elem, tracks); setTracks(elem, tracks);
requireHlsPlayer(function () {
var hls = new Hls(); var hls = new Hls();
hls.loadSource(val); hls.loadSource(val);
hls.attachMedia(elem); hls.attachMedia(elem);
@ -395,6 +414,7 @@
elem.play(); elem.play();
}); });
hlsPlayer = hls; hlsPlayer = hls;
});
} else { } else {
@ -880,16 +900,7 @@
self.init = function () { self.init = function () {
return new Promise(function (resolve, reject) { return Promise.resolve();
if (options.type == 'video' && enableHlsPlayer()) {
requireHlsPlayer(resolve);
} else {
resolve();
}
});
}; };
if (options.type == 'audio') { if (options.type == 'audio') {

View file

@ -1,4 +1,4 @@
define(['appSettings', 'datetime', 'mediaInfo', 'scrollStyles', 'paper-icon-button-light'], function (appSettings, datetime, mediaInfo) { define(['appSettings', 'datetime', 'mediaInfo', 'browser', 'scrollStyles', 'paper-icon-button-light'], function (appSettings, datetime, mediaInfo, browser) {
function createVideoPlayer(self) { function createVideoPlayer(self) {
@ -710,7 +710,7 @@
html += '<div id="pause" class="status"></div>'; html += '<div id="pause" class="status"></div>';
html += '</div>'; html += '</div>';
var hiddenOnIdleClass = AppInfo.isNativeApp && browserInfo.android ? 'hiddenOnIdle hide' : 'hiddenOnIdle'; var hiddenOnIdleClass = AppInfo.isNativeApp && browser.android ? 'hiddenOnIdle hide' : 'hiddenOnIdle';
html += '<div class="videoTopControls ' + hiddenOnIdleClass + '">'; html += '<div class="videoTopControls ' + hiddenOnIdleClass + '">';
html += '<div class="videoTopControlsLogo"></div>'; html += '<div class="videoTopControlsLogo"></div>';
@ -984,7 +984,7 @@
self.playVideo = function (item, mediaSource, startPosition, callback) { self.playVideo = function (item, mediaSource, startPosition, callback) {
if (browserInfo.msie) { if (browser.msie) {
if (!window.MediaSource || !mediaSource.RunTimeTicks) { if (!window.MediaSource || !mediaSource.RunTimeTicks) {
alert('Playback of this content is not supported in Internet Explorer. For a better experience, please try a modern browser such as Google Chrome, Firefox, Opera, or Microsoft Edge.'); alert('Playback of this content is not supported in Internet Explorer. For a better experience, please try a modern browser such as Google Chrome, Firefox, Opera, or Microsoft Edge.');
@ -998,15 +998,20 @@
self.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) { self.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) {
var onReadyToPlay = function () {
self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback);
};
var isHls = streamInfo.url.toLowerCase().indexOf('.m3u8') != -1; var isHls = streamInfo.url.toLowerCase().indexOf('.m3u8') != -1;
// Huge hack alert. Safari doesn't seem to like if the segments aren't available right away when playback starts // Huge hack alert. Safari doesn't seem to like if the segments aren't available right away when playback starts
// This will start the transcoding process before actually feeding the video url into the player // This will start the transcoding process before actually feeding the video url into the player
// Edit: Also seeing stalls from hls.js // Edit: Also seeing stalls from hls.js
if (!mediaSource.RunTimeTicks && isHls && !browserInfo.edge) { if (!mediaSource.RunTimeTicks && isHls && !browser.edge) {
var hlsPlaylistUrl = streamInfo.url.replace('master.m3u8', 'live.m3u8');
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var hlsPlaylistUrl = streamInfo.url.replace('master.m3u8', 'live.m3u8');
ApiClient.ajax({ ApiClient.ajax({
type: 'GET', type: 'GET',
@ -1016,17 +1021,14 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
streamInfo.url = hlsPlaylistUrl; streamInfo.url = hlsPlaylistUrl;
// add a delay to continue building up the buffer. without this we see failures in safari mobile onReadyToPlay();
setTimeout(function () {
self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback);
}, 2000);
}, function () { }, function () {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
} else { } else {
self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback); onReadyToPlay();
} }
}); });
}); });
@ -1064,7 +1066,7 @@
elem.classList.remove('hide'); elem.classList.remove('hide');
if (!browserInfo.animate || browserInfo.slow) { if (!browser.animate || browser.slow) {
return; return;
} }
@ -1262,7 +1264,7 @@
function onClick() { function onClick() {
if (!browserInfo.mobile) { if (!browser.mobile) {
if (this.paused()) { if (this.paused()) {
self.unpause(); self.unpause();
} else { } else {
@ -1272,7 +1274,7 @@
} }
function onDoubleClick() { function onDoubleClick() {
if (!browserInfo.mobile) { if (!browser.mobile) {
self.toggleFullscreen(); self.toggleFullscreen();
} }
} }