From 5fb6288ba238b0c02519300de2ae051d604f0d5e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Jan 2017 03:02:08 -0500 Subject: [PATCH] update video osd --- .../emby-webcomponents/.bower.json | 8 ++-- .../playback/playbackmanager.js | 42 +++++++++++++++++-- .../emby-webcomponents/qualityoptions.js | 2 +- dashboard-ui/scripts/videoosd.js | 28 +++++-------- dashboard-ui/videoosd.html | 2 +- 5 files changed, 55 insertions(+), 27 deletions(-) diff --git a/dashboard-ui/bower_components/emby-webcomponents/.bower.json b/dashboard-ui/bower_components/emby-webcomponents/.bower.json index 0cf4c0d727..a53d6f1d72 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/.bower.json +++ b/dashboard-ui/bower_components/emby-webcomponents/.bower.json @@ -14,12 +14,12 @@ }, "devDependencies": {}, "ignore": [], - "version": "1.4.439", - "_release": "1.4.439", + "version": "1.4.441", + "_release": "1.4.441", "_resolution": { "type": "version", - "tag": "1.4.439", - "commit": "83d5b3f38e168da5f42415f346c8d624fc8523e8" + "tag": "1.4.441", + "commit": "f887007409e0ab3a8ca1f5b2a58aac519fc2c5cc" }, "_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_target": "^1.2.1", diff --git a/dashboard-ui/bower_components/emby-webcomponents/playback/playbackmanager.js b/dashboard-ui/bower_components/emby-webcomponents/playback/playbackmanager.js index e3b0d9b4eb..36b7849d13 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/playback/playbackmanager.js +++ b/dashboard-ui/bower_components/emby-webcomponents/playback/playbackmanager.js @@ -191,6 +191,7 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g "SetVolume", "SetAudioStreamIndex", "SetSubtitleStreamIndex", + "SetMaxStreamingBitrate", "DisplayContent", "GoToSearch", "DisplayMessage", @@ -376,6 +377,9 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g case 'SetSubtitleStreamIndex': self.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index), player); break; + case 'SetMaxStreamingBitrate': + self.setMaxStreamingBitrate(parseInt(cmd.Arguments.Bitrate), player); + break; case 'ToggleFullscreen': self.toggleFullscreen(player); break; @@ -639,6 +643,36 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g } }; + self.getMaxStreamingBitrate = function (player) { + + player = player || currentPlayer; + if (player && !enableLocalPlaylistManagement(player)) { + return player.getMaxStreamingBitrate(); + } + + return getPlayerData(player).maxStreamingBitrate || appSettings.maxStreamingBitrate(); + }; + + self.setMaxStreamingBitrate = function (bitrate, player) { + + player = player || currentPlayer; + if (player && !enableLocalPlaylistManagement(player)) { + return player.setMaxStreamingBitrate(bitrate); + } + + if (bitrate) { + appSettings.enableAutomaticBitrateDetection(false); + } else { + appSettings.enableAutomaticBitrateDetection(true); + } + + appSettings.maxStreamingBitrate(bitrate); + + changeStream(player, getCurrentTicks(player), { + MaxStreamingBitrate: bitrate + }); + }; + self.getSubtitleStreamIndex = function (player) { player = player || currentPlayer; @@ -893,8 +927,6 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g params = params || {}; - var currentSrc = player.currentSrc(); - var liveStreamId = getPlayerData(player).streamInfo.liveStreamId; var playSessionId = getPlayerData(player).streamInfo.playSessionId; @@ -913,7 +945,9 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g ticks = parseInt(ticks); } - getPlaybackInfo(apiClient, currentItem.Id, deviceProfile, appSettings.maxStreamingBitrate(), ticks, currentMediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).then(function (result) { + var maxBitrate = params.MaxStreamingBitrate || self.getMaxStreamingBitrate(player); + + getPlaybackInfo(apiClient, currentItem.Id, deviceProfile, maxBitrate, ticks, currentMediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).then(function (result) { if (validatePlaybackInfoResult(result)) { @@ -930,6 +964,7 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g getPlayerData(player).subtitleStreamIndex = subtitleStreamIndex; getPlayerData(player).audioStreamIndex = audioStreamIndex; + getPlayerData(player).maxStreamingBitrate = maxBitrate; changeStreamToUrl(apiClient, player, playSessionId, streamInfo); }); @@ -1536,6 +1571,7 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g streamInfo.fullscreen = playOptions.fullscreen; getPlayerData(player).isChangingStream = false; + getPlayerData(player).maxStreamingBitrate = maxBitrate; return player.play(streamInfo).then(function () { onPlaybackStarted(player, streamInfo, mediaSource); diff --git a/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js b/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js index 53725ce7eb..b83c307ddf 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js +++ b/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js @@ -36,7 +36,7 @@ options.push({ name: '720p - 6Mbps', maxHeight: 720, bitrate: 6000000 }); options.push({ name: '720p - 5Mbps', maxHeight: 720, bitrate: 5000000 }); - } else if (maxAllowedWidth >= 700) { + } else if (maxAllowedWidth >= 620) { options.push({ name: '480p - 4Mbps', maxHeight: 480, bitrate: 4000001 }); options.push({ name: '480p - 3Mbps', maxHeight: 480, bitrate: 3000001 }); options.push({ name: '480p - 2.5Mbps', maxHeight: 480, bitrate: 2500000 }); diff --git a/dashboard-ui/scripts/videoosd.js b/dashboard-ui/scripts/videoosd.js index d1a5a5c74c..7ff98dd2bc 100644 --- a/dashboard-ui/scripts/videoosd.js +++ b/dashboard-ui/scripts/videoosd.js @@ -87,9 +87,7 @@ var currentPlayerSupportedCommands = []; var currentRuntimeTicks = 0; var lastUpdateTime = 0; - var lastPlayerState = {}; var isEnabled; - var currentItem; var nowPlayingVolumeSlider = view.querySelector('.osdVolumeSlider'); var nowPlayingVolumeSliderContainer = view.querySelector('.osdVolumeSliderContainer'); @@ -486,6 +484,8 @@ function onPlaybackStopped(e, state) { + currentRuntimeTicks = null; + console.log('nowplaying event: ' + e.type); var player = this; @@ -559,8 +559,6 @@ lastUpdateTime = now; var player = this; - var state = lastPlayerState; - var nowPlayingItem = state.NowPlayingItem || {}; currentRuntimeTicks = playbackManager.duration(player); updateTimeDisplay(playbackManager.currentTime(player), currentRuntimeTicks); } @@ -576,8 +574,6 @@ function updatePlayerStateInternal(event, state) { - lastPlayerState = state; - var playerInfo = playbackManager.getPlayerInfo(); var playState = state.PlayState || {}; @@ -619,7 +615,7 @@ updateNowPlayingInfo(state); - if (state.MediaSource && state.MediaSource.SupportsTranscoding) { + if (state.MediaSource && state.MediaSource.SupportsTranscoding && supportedCommands.indexOf('SetMaxStreamingBitrate') !== -1) { view.querySelector('.btnSettings').classList.remove('hide'); } else { view.querySelector('.btnSettings').classList.add('hide'); @@ -750,12 +746,12 @@ //var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase(); //var isStatic = currentSrc.indexOf('static=true') != -1; - var videoStream = lastPlayerState.MediaSource.MediaStreams.filter(function (stream) { - return stream.Type == "Video"; + var videoStream = playbackManager.currentMediaSource(currentPlayer).MediaStreams.filter(function (stream) { + return stream.Type === "Video"; })[0]; var videoWidth = videoStream ? videoStream.Width : null; - var options = qualityoptions.getVideoQualityOptions(lastPlayerState.MaxStreamingBitrate, videoWidth); + var options = qualityoptions.getVideoQualityOptions(playbackManager.getMaxStreamingBitrate(currentPlayer), videoWidth); //if (isStatic) { // options[0].name = "Direct"; @@ -781,14 +777,12 @@ selectedId = selectedId.length ? selectedId[0].bitrate : null; actionsheet.show({ items: menuItems, - // history.back() will cause the video player to stop - enableHistory: false, positionTo: btn, callback: function (id) { var bitrate = parseInt(id); - if (bitrate != selectedId) { - //self.onQualityOptionSelected(bitrate); + if (bitrate !== selectedId) { + playbackManager.setMaxStreamingBitrate(bitrate, currentPlayer); } } }); @@ -930,9 +924,7 @@ nowPlayingPositionSlider.getBubbleText = function (value) { - var state = lastPlayerState; - - if (!state || !state.NowPlayingItem || !currentRuntimeTicks) { + if (!currentRuntimeTicks) { return '--:--'; } @@ -1007,7 +999,7 @@ function renderScenePicker(progressPct) { chapterPcts = []; - var item = currentItem; + var item = playbackManager.currentItem(currentPlayer); if (!item) { return; } diff --git a/dashboard-ui/videoosd.html b/dashboard-ui/videoosd.html index 80bc13a390..aaad6ccf8d 100644 --- a/dashboard-ui/videoosd.html +++ b/dashboard-ui/videoosd.html @@ -208,7 +208,7 @@