audio/video player fixes

This commit is contained in:
Luke Pulverenti 2014-04-11 23:48:57 -04:00
parent bd697d36fc
commit 85a08beb3e
9 changed files with 121 additions and 66 deletions

View file

@ -821,7 +821,7 @@
audioBitrate: mp4Quality.audioBitrate,
VideoCodec: mp4Quality.videoCodec,
AudioCodec: mp4Quality.audioCodec,
// None of the browsers seem to like this
EnableAutoStreamCopy: false
@ -942,9 +942,7 @@
updateVolumeButtons(vol);
}).on("playing.once", function () {
video.off("playing.once");
}).one("playing", function () {
self.onPlaybackStart(this, item, mediaSource);

View file

@ -106,11 +106,13 @@
var currentSrc = element.currentSrc;
if (params.AudioStreamIndex != null) {
currentSrc = replaceQueryString(currentSrc, 'AudioStreamIndex', params.AudioStreamIndex);
}
if (params.SubtitleStreamIndex != null) {
currentSrc = replaceQueryString(currentSrc, 'SubtitleStreamIndex', (params.SubtitleStreamIndex == -1 ? '' : params.SubtitleStreamIndex));
if (currentItem.MediaType == "Video") {
if (params.AudioStreamIndex != null) {
currentSrc = replaceQueryString(currentSrc, 'AudioStreamIndex', params.AudioStreamIndex);
}
if (params.SubtitleStreamIndex != null) {
currentSrc = replaceQueryString(currentSrc, 'SubtitleStreamIndex', (params.SubtitleStreamIndex == -1 ? '' : params.SubtitleStreamIndex));
}
}
var maxWidth = params.MaxWidth || getParameterByName('MaxWidth', currentSrc);
@ -122,25 +124,32 @@
var transcodingExtension = self.getTranscodingExtension();
var finalParams = self.getFinalVideoParams(currentMediaSource, maxWidth, bitrate, audioStreamIndex, subtitleStreamIndex, transcodingExtension);
currentSrc = replaceQueryString(currentSrc, 'MaxWidth', finalParams.maxWidth);
currentSrc = replaceQueryString(currentSrc, 'VideoBitrate', finalParams.videoBitrate);
currentSrc = replaceQueryString(currentSrc, 'AudioBitrate', finalParams.audioBitrate);
currentSrc = replaceQueryString(currentSrc, 'Static', finalParams.isStatic);
var isStatic;
if (currentItem.MediaType == "Video") {
currentSrc = replaceQueryString(currentSrc, 'AudioCodec', finalParams.audioCodec);
currentSrc = replaceQueryString(currentSrc, 'VideoCodec', finalParams.videoCodec);
var finalParams = self.getFinalVideoParams(currentMediaSource, maxWidth, bitrate, audioStreamIndex, subtitleStreamIndex, transcodingExtension);
currentSrc = replaceQueryString(currentSrc, 'profile', finalParams.profile || '');
currentSrc = replaceQueryString(currentSrc, 'level', finalParams.level || '');
currentSrc = replaceQueryString(currentSrc, 'MaxWidth', finalParams.maxWidth);
currentSrc = replaceQueryString(currentSrc, 'VideoBitrate', finalParams.videoBitrate);
if (finalParams.isStatic) {
currentSrc = currentSrc.replace('.webm', '.mp4').replace('.m3u8', '.mp4');
} else {
currentSrc = currentSrc.replace('.mp4', transcodingExtension).replace('.m4v', transcodingExtension);
currentSrc = replaceQueryString(currentSrc, 'VideoCodec', finalParams.videoCodec);
currentSrc = replaceQueryString(currentSrc, 'profile', finalParams.profile || '');
currentSrc = replaceQueryString(currentSrc, 'level', finalParams.level || '');
if (finalParams.isStatic) {
currentSrc = currentSrc.replace('.webm', '.mp4').replace('.m3u8', '.mp4');
} else {
currentSrc = currentSrc.replace('.mp4', transcodingExtension).replace('.m4v', transcodingExtension);
}
currentSrc = replaceQueryString(currentSrc, 'AudioBitrate', finalParams.audioBitrate);
currentSrc = replaceQueryString(currentSrc, 'Static', finalParams.isStatic);
currentSrc = replaceQueryString(currentSrc, 'AudioCodec', finalParams.audioCodec);
isStatic = finalParams.isStatic;
}
if (finalParams.isStatic || !ticks) {
if (isStatic || !ticks) {
currentSrc = replaceQueryString(currentSrc, 'starttimeticks', '');
} else {
currentSrc = replaceQueryString(currentSrc, 'starttimeticks', ticks);
@ -148,23 +157,29 @@
clearProgressInterval();
$(element).off('ended.playbackstopped').off('ended.playnext').on("play.onceafterseek", function () {
$(element).off('ended.playbackstopped').off('ended.playnext').one("play", function () {
self.updateCanClientSeek(this);
$(this).off('play.onceafterseek').on('ended.playbackstopped', self.onPlaybackStopped).on('ended.playnext', self.playNextAfterEnded);
$(this).on('ended.playbackstopped', self.onPlaybackStopped).on('ended.playnext', self.playNextAfterEnded);
self.startProgressInterval(currentItem.Id, currentMediaSource.Id);
sendProgressUpdate(currentItem.Id, currentMediaSource.Id);
});
ApiClient.stopActiveEncodings().done(function () {
if (currentItem.MediaType == "Video") {
ApiClient.stopActiveEncodings().done(function() {
self.startTimeTicksOffset = ticks;
element.src = currentSrc;
});
} else {
self.startTimeTicksOffset = ticks;
element.src = currentSrc;
});
element.play();
}
}
};
@ -463,7 +478,7 @@
if (!item) {
throw new Error('item cannot be null');
}
var mediaControls = $("#videoControls");
var state = self.getPlayerState(currentMediaElement, item, currentMediaSource);
@ -679,7 +694,6 @@
self.seek = function (position) {
self.changeStream(position);
};
self.mute = function () {
@ -900,16 +914,20 @@
if (item.CurrentProgram) {
seriesName = item.CurrentProgram.Name;
}
else if (item.SeriesName || item.Album || item.ProductionYear) {
seriesName = item.SeriesName || item.Album || item.ProductionYear;
else if (item.SeriesName || item.Album) {
seriesName = item.SeriesName || item.Album;
}
if (seriesName) {
itemName = item.SeriesName || item.Album || item.CurrentProgram;
itemName = seriesName;
itemSubName = name;
} else {
itemName = name;
}
if (!itemSubName && item.ProductionYear) {
itemSubName = item.ProductionYear;
}
}
var state = {
@ -1122,12 +1140,10 @@
self.onVolumeChanged(this);
}).on("playing.once", function () {
}).one("playing", function () {
$('.mediaPlayerAudioContainer').hide();
$(this).off("playing.once");
self.onPlaybackStart(this, item, mediaSource);
}).on("pause", function () {

View file

@ -130,9 +130,9 @@
if (currentPlayer && lastPlayerState) {
var ticks = lastPlayerState.runtimeTicks * this.value / 100;
currentPlayer.seek(ticks);
var newPercent = parseFloat(this.value);
var newPositionTicks = (newPercent / 100) * lastPlayerState.runtimeTicks;
currentPlayer.seek(Math.floor(newPositionTicks));
}
});
}
@ -254,10 +254,10 @@
});
}
else if (item.Type == "TvChannel" || item.Type == "Recording") {
else if (state.itemType == "TvChannel" || state.itemType == "Recording") {
url = "css/images/items/detail/tv.png";
}
else if (item.MediaType == "Audio") {
else if (state.mediaType == "Audio") {
url = "css/images/items/detail/audio.png";
}
else {
@ -305,7 +305,7 @@
// in the event of a stop->play command
nowPlayingBarTimeout = setTimeout(function () {
getNowPlayingBar().hide();
}, 200);
}, 500);
}
function onPlaybackStopped(e, state) {

View file

@ -1311,7 +1311,7 @@ $(function () {
videoPlayerHtml += '<button onclick="MediaPlayer.showChaptersFlyout();" id="video-chaptersButton" class="mediaButton chaptersButton" title="Scenes" type="button" data-icon="video" data-iconpos="notext" data-inline="true">Scenes</button>';
videoPlayerHtml += '<div class="mediaFlyoutContainer"><div id="video-chaptersFlyout" style="display:none;" class="mediaPlayerFlyout chaptersFlyout"></div></div>';
videoPlayerHtml += '<button onclick="MediaPlayer.toggleFullscreen();" id="video-fullscreenButton" class="mediaButton fullscreenButton" title="Fullscreen" type="button" data-icon="action" data-iconpos="notext" data-inline="true">Fullscreen</button>';
videoPlayerHtml += '<button onclick="MediaPlayer.toggleFullscreen();" id="video-fullscreenButton" class="mediaButton fullscreenButton" title="Fullscreen" type="button" data-icon="expand" data-iconpos="notext" data-inline="true">Fullscreen</button>';
videoPlayerHtml += '</div>'; // video-advanced-controls