From 95ae6d49af480ca000b42e945df31f0fa220c996 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 13:45:10 +0300 Subject: [PATCH 01/11] Adjust ABR rules for Dash.js --- .../popcorn.HTMLAdaptiveMediaElement.js | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 7aeb3e543..7a1e4aa2b 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -9,8 +9,8 @@ function isMicrosoftBrowser() { return navigator.appName === 'Microsoft Internet Explorer' || - (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Edge') > -1) || - (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Trident') > -1) + (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Edge') > -1) || + (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Trident') > -1) } function canPlaySrc(src) { @@ -70,7 +70,7 @@ function wrapMedia(id, mediaType) { var parent = typeof id === 'string' ? document.querySelector(id) : id, - media = document.createElement(mediaType); + media = document.createElement(mediaType); var impl = { autoplay: EMPTY_STRING, @@ -78,11 +78,11 @@ media.dispatchEvent = function (name, data) { var customEvent = document.createEvent('CustomEvent'), - detail = { - type: name, - target: media.parentNode, - data: data - }; + detail = { + type: name, + target: media.parentNode, + data: data + }; customEvent.initCustomEvent(media._eventNamespace + name, false, false, detail); document.dispatchEvent(customEvent); @@ -171,6 +171,21 @@ media.src = fallbackMedia; } }); + + // ABR strategy to throughput + player.setABRStrategy('abrThroughput'); + + // set buffer to 5 seconds + player.setBufferToKeep(5); + player.setBufferAheadToKeep(5); + player.setStableBufferTime(5); + + // descrease quality slowdown + player.setCatchUpPlaybackRate(0.25); + + // optimize switch-up + player.setFastSwitchEnabled(true); + player.initialize(media, adaptiveMedia, false); }); break; From d3a342234f718b7905942d01209a5474f285966e Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 15:29:02 +0300 Subject: [PATCH 02/11] Adjust ABR rules for Dash.js --- .../popcorn.HTMLAdaptiveMediaElement.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 7a1e4aa2b..47eaa52fa 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -172,19 +172,15 @@ } }); - // ABR strategy to throughput - player.setABRStrategy('abrThroughput'); + player.addEventListener("initialized", function(){ + var bitrates = player.getBitrateInfoListFor("video"), + // bitrates are sorted from lowest to the best values + // so the last one has the best quality + maxQuality = bitrates[bitrates.length-1].qualityIndex; + // set max quality + player.setQualityFor("video", maxQuality); - // set buffer to 5 seconds - player.setBufferToKeep(5); - player.setBufferAheadToKeep(5); - player.setStableBufferTime(5); - - // descrease quality slowdown - player.setCatchUpPlaybackRate(0.25); - - // optimize switch-up - player.setFastSwitchEnabled(true); + }); player.initialize(media, adaptiveMedia, false); }); From b9432a57d61626cdfa7c00479461044b8d0afc99 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 15:33:43 +0300 Subject: [PATCH 03/11] Adjust ABR rules for Dash.js fix typo --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 47eaa52fa..297a26229 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -172,7 +172,7 @@ } }); - player.addEventListener("initialized", function(){ + player.on("initialized", function() { var bitrates = player.getBitrateInfoListFor("video"), // bitrates are sorted from lowest to the best values // so the last one has the best quality From b1f2b7aefaafee431ec05422d190ccadacd9224a Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 15:44:05 +0300 Subject: [PATCH 04/11] Adjust ABR rules for Dash.js set correct event names --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 297a26229..920410b6b 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -161,7 +161,7 @@ case 'mpd': loadDashJs(function() { var player = dashjs.MediaPlayer().create(); - player.on('error', function(event) { + player.on(MediaPlayer.events.ERROR, function(event) { if (event.error.code === 23) { // 23 says `message: "mediasource is not supported"`, so fallback to HLS // as it happens mainly on Safari iOS @@ -172,7 +172,7 @@ } }); - player.on("initialized", function() { + player.on(MediaPlayer.events.SOURCE_INITIALIZED, function() { var bitrates = player.getBitrateInfoListFor("video"), // bitrates are sorted from lowest to the best values // so the last one has the best quality From 92b97e73a43185d9995f25ab97b27257a84325f5 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 15:48:11 +0300 Subject: [PATCH 05/11] Adjust ABR rules for Dash.js --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 920410b6b..3affd4dce 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -161,7 +161,7 @@ case 'mpd': loadDashJs(function() { var player = dashjs.MediaPlayer().create(); - player.on(MediaPlayer.events.ERROR, function(event) { + player.on(dashjs.MediaPlayer.events.ERROR, function(event) { if (event.error.code === 23) { // 23 says `message: "mediasource is not supported"`, so fallback to HLS // as it happens mainly on Safari iOS @@ -172,7 +172,7 @@ } }); - player.on(MediaPlayer.events.SOURCE_INITIALIZED, function() { + player.on(dashjs.MediaPlayer.events.SOURCE_INITIALIZED, function() { var bitrates = player.getBitrateInfoListFor("video"), // bitrates are sorted from lowest to the best values // so the last one has the best quality From 40f6798125e22291068307be36519ef18364ea14 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 15:52:34 +0300 Subject: [PATCH 06/11] Adjust ABR rules for Dash.js --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 3affd4dce..0f4dbb234 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -172,7 +172,7 @@ } }); - player.on(dashjs.MediaPlayer.events.SOURCE_INITIALIZED, function() { + player.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function() { var bitrates = player.getBitrateInfoListFor("video"), // bitrates are sorted from lowest to the best values // so the last one has the best quality From 58b671355c343c1680064b82b12eab85a9bd5f65 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 16:19:12 +0300 Subject: [PATCH 07/11] Adjust ABR rules for Dash.js kickout video with the best quality --- .../popcorn.HTMLAdaptiveMediaElement.js | 406 +++++++++--------- 1 file changed, 207 insertions(+), 199 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 0f4dbb234..5fe3c7ccd 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -5,219 +5,227 @@ */ (function (Popcorn, document) { - var EMPTY_STRING = ''; - - function isMicrosoftBrowser() { - return navigator.appName === 'Microsoft Internet Explorer' || - (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Edge') > -1) || - (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Trident') > -1) - } - - function canPlaySrc(src) { - var sources = src.split('|'); - for (var i = 0; i < sources.length; i++) { - if (/(.)*\.(mp4|m3u8|mpd)/.test(sources[i])) { - return 'probably'; - } + var EMPTY_STRING = ''; + + function isMicrosoftBrowser() { + return navigator.appName === 'Microsoft Internet Explorer' || + (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Edge') > -1) || + (navigator.appName === "Netscape" && navigator.appVersion.indexOf('Trident') > -1) } - return EMPTY_STRING; - } - - function loadDashJs(callback) { - if (window.dashjs) { - callback(); - } else { - var requireDefine; - var script = document.createElement('script'); - script.addEventListener('load', function() { - window.define = requireDefine; - callback(); - }); - script.src = '//cdn.dashjs.org/latest/dash.all.min.js'; - requireDefine = window.define; - window.define = function() {}; - document.head.appendChild(script); + + function canPlaySrc(src) { + var sources = src.split('|'); + for (var i = 0; i < sources.length; i++) { + if (/(.)*\.(mp4|m3u8|mpd)/.test(sources[i])) { + return 'probably'; + } + } + return EMPTY_STRING; } - } - - function loadHlsJs(media, callback) { - if (window.Hls) { - if(Hls.isSupported() && window.Hls.instance) { - callback(window.Hls.instance); - } else { - callback(); - } - } else { - var requireDefine; - var script = document.createElement('script'); - script.addEventListener('load', function() { - window.define = requireDefine; - if(Hls.isSupported()) { - var hls = new Hls(); - hls.startLevel = -1; - window.Hls.instance = hls; - callback(hls); + + function loadDashJs(callback) { + if (window.dashjs) { + callback(); } else { - callback(); + var requireDefine; + var script = document.createElement('script'); + script.addEventListener('load', function () { + window.define = requireDefine; + callback(); + }); + script.src = '//cdn.dashjs.org/latest/dash.all.min.js'; + requireDefine = window.define; + window.define = function () { + }; + document.head.appendChild(script); } - }); - script.src = '//cdn.jsdelivr.net/npm/hls.js@latest'; - requireDefine = window.define; - window.define = function() {}; - document.head.appendChild(script); } - } - - function wrapMedia(id, mediaType) { - var parent = typeof id === 'string' ? document.querySelector(id) : id, - media = document.createElement(mediaType); - - var impl = { - autoplay: EMPTY_STRING, - }; - - media.dispatchEvent = function (name, data) { - var customEvent = document.createEvent('CustomEvent'), - detail = { - type: name, - target: media.parentNode, - data: data - }; - - customEvent.initCustomEvent(media._eventNamespace + name, false, false, detail); - document.dispatchEvent(customEvent); - }; - - media._eventNamespace = Popcorn.guid('HTMLAdaptiveMediaElement::'); - - media.setAttribute('playsinline', ''); - media.setAttribute('webkit-playsinline', ''); - var source = document.createElement('source'); - media.appendChild(source); + function loadHlsJs(media, callback) { + if (window.Hls) { + if (Hls.isSupported() && window.Hls.instance) { + callback(window.Hls.instance); + } else { + callback(); + } + } else { + var requireDefine; + var script = document.createElement('script'); + script.addEventListener('load', function () { + window.define = requireDefine; + if (Hls.isSupported()) { + var hls = new Hls(); + hls.startLevel = -1; + window.Hls.instance = hls; + callback(hls); + } else { + callback(); + } + }); + script.src = '//cdn.jsdelivr.net/npm/hls.js@latest'; + requireDefine = window.define; + window.define = function () { + }; + document.head.appendChild(script); + } + } - parent.appendChild(media); + function wrapMedia(id, mediaType) { + var parent = typeof id === 'string' ? document.querySelector(id) : id, + media = document.createElement(mediaType); + + var impl = { + autoplay: EMPTY_STRING, + }; + + media.dispatchEvent = function (name, data) { + var customEvent = document.createEvent('CustomEvent'), + detail = { + type: name, + target: media.parentNode, + data: data + }; + + customEvent.initCustomEvent(media._eventNamespace + name, false, false, detail); + document.dispatchEvent(customEvent); + }; + + media._eventNamespace = Popcorn.guid('HTMLAdaptiveMediaElement::'); + + media.setAttribute('playsinline', ''); + media.setAttribute('webkit-playsinline', ''); + + var source = document.createElement('source'); + media.appendChild(source); + + parent.appendChild(media); + + [ + 'seeked', 'timeupdate', 'progress', 'play', + 'pause', 'seeking', 'waiting', 'playing', + 'error', 'volumechange', 'loadedmetadata' + ].forEach(function (event) { + media.addEventListener(event, function () { + media.dispatchEvent(event); + }); + }); + + // Add the helper function _canPlaySrc so this works like other wrappers. + media._canPlaySrc = canPlaySrc; + + Object.defineProperties(media, { + autoplay: { + get: function () { + return impl.autoplay; + }, + set: function (aValue) { + impl.autoplay = (typeof aValue === 'string' || aValue === true); + } + }, + src: { + get: function () { + return media._src; + }, + set: function (aSrc) { + function setRawSource(source) { + // IE and Edge do not understand source setting here for MSE BLOB + if (isMicrosoftBrowser()) { + if (source && source !== media.getAttribute('src')) { + media.setAttribute('src', source); + media.load(); + } + } else { + var sources = media.getElementsByTagName('source'); + if (source && source !== sources[0].src) { + sources[0].src = source; + media.load(); + } + } + } - [ - 'seeked', 'timeupdate', 'progress', 'play', - 'pause', 'seeking', 'waiting', 'playing', - 'error', 'volumechange', 'loadedmetadata' - ].forEach(function (event) { - media.addEventListener(event, function() { - media.dispatchEvent(event); - }); - }); + media._src = aSrc; - // Add the helper function _canPlaySrc so this works like other wrappers. - media._canPlaySrc = canPlaySrc; + function findMediaSource(sources, acceptableSources) { + return sources.filter(function (source) { + var extension = source.split('.').reverse()[0]; + return acceptableSources.indexOf(extension) !== -1; + })[0]; + } - Object.defineProperties(media, { - autoplay: { - get: function() { - return impl.autoplay; - }, - set: function(aValue) { - impl.autoplay = (typeof aValue === 'string' || aValue === true); - } - }, - src: { - get: function() { - return media._src; - }, - set: function(aSrc) { - function setRawSource(source) { - // IE and Edge do not understand source setting here for MSE BLOB - if (isMicrosoftBrowser()) { - if(source && source !== media.getAttribute('src')) { - media.setAttribute('src', source); - media.load(); - } - } else { - var sources = media.getElementsByTagName('source'); - if(source && source !== sources[0].src) { - sources[0].src = source; - media.load(); - } - } - } - media._src = aSrc; - function findMediaSource(sources, acceptableSources) { - return sources.filter(function(source) { - var extension = source.split('.').reverse()[0]; - return acceptableSources.indexOf(extension) !== -1; - })[0]; - } - - var sources = media._src.split('|'); - var hlsMedia = findMediaSource(sources, ['m3u8']); - var dashMedia = findMediaSource(sources, ['mpd']); - var fallbackMedia = findMediaSource(sources, ['mp4', 'webm']); - - - if (dashMedia || hlsMedia) { - var adaptiveMedia = dashMedia || hlsMedia; - var extension = adaptiveMedia.split('.').reverse()[0]; - switch (extension) { - case 'mpd': - loadDashJs(function() { - var player = dashjs.MediaPlayer().create(); - player.on(dashjs.MediaPlayer.events.ERROR, function(event) { - if (event.error.code === 23) { - // 23 says `message: "mediasource is not supported"`, so fallback to HLS - // as it happens mainly on Safari iOS - media.src = hlsMedia || fallbackMedia; + var sources = media._src.split('|'); + var hlsMedia = findMediaSource(sources, ['m3u8']); + var dashMedia = findMediaSource(sources, ['mpd']); + var fallbackMedia = findMediaSource(sources, ['mp4', 'webm']); + + + if (dashMedia || hlsMedia) { + var adaptiveMedia = dashMedia || hlsMedia; + var extension = adaptiveMedia.split('.').reverse()[0]; + switch (extension) { + case 'mpd': + loadDashJs(function () { + var player = dashjs.MediaPlayer().create(); + player.on(dashjs.MediaPlayer.events.ERROR, function (event) { + if (event.error.code === 23) { + // 23 says `message: "mediasource is not supported"`, so fallback to HLS + // as it happens mainly on Safari iOS + media.src = hlsMedia || fallbackMedia; + } else { + // otherwise MPD manifest is not available so fallback to regular media file + media.src = fallbackMedia; + } + }); + + player.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function () { + var bitrates = player.getBitrateInfoListFor("video"), + // bitrates are sorted from lowest to the best values + // so the last one has the best quality + maxQuality = bitrates[bitrates.length - 1].qualityIndex; + player.setAutoSwitchQuality(false); + // set max quality + player.setQualityFor("video", maxQuality); + setTimeout(function() { + player.setAutoSwitchQuality(true); + }, 1000); + + }); + + player.initialize(media, adaptiveMedia, false); + }); + break; + case 'm3u8': + loadHlsJs(media, function (hls) { + if (Hls.isSupported()) { + hls.on(Hls.Events.ERROR, function (error, data) { + // fallback to default media source + if (data.type === 'networkError') { + media.src = fallbackMedia; + } + }); + hls.loadSource(adaptiveMedia); + hls.attachMedia(media); + } else if (media.canPlayType('application/vnd.apple.mpegurl')) { + setRawSource(adaptiveMedia); + } + }); + break; + default: + setRawSource(adaptiveMedia); + break; + } } else { - // otherwise MPD manifest is not available so fallback to regular media file - media.src = fallbackMedia; + setRawSource(fallbackMedia || aSrc); } - }); - - player.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function() { - var bitrates = player.getBitrateInfoListFor("video"), - // bitrates are sorted from lowest to the best values - // so the last one has the best quality - maxQuality = bitrates[bitrates.length-1].qualityIndex; - // set max quality - player.setQualityFor("video", maxQuality); - - }); - - player.initialize(media, adaptiveMedia, false); - }); - break; - case 'm3u8': - loadHlsJs(media, function(hls) { - if(Hls.isSupported()) { - hls.on(Hls.Events.ERROR, function (error, data) { - // fallback to default media source - if (data.type === 'networkError') { - media.src = fallbackMedia; - } - }); - hls.loadSource(adaptiveMedia); - hls.attachMedia(media); - } else if (media.canPlayType('application/vnd.apple.mpegurl')) { - setRawSource(adaptiveMedia); - } - }); - break; - default: - setRawSource(adaptiveMedia); - break; + } } - } else { - setRawSource(fallbackMedia || aSrc); - } - } - } - }); + }); - return media; - } + return media; + } - Popcorn.HTMLAdaptiveMediaElement = function (id) { - return wrapMedia(id, 'video'); - }; - Popcorn.HTMLAdaptiveMediaElement._canPlaySrc = canPlaySrc; + Popcorn.HTMLAdaptiveMediaElement = function (id) { + return wrapMedia(id, 'video'); + }; + Popcorn.HTMLAdaptiveMediaElement._canPlaySrc = canPlaySrc; }(Popcorn, window.document)); From 6804d572b9bb99ac0a2d87e4e8648cd810890da7 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 16:23:54 +0300 Subject: [PATCH 08/11] Adjust ABR rules for Dash.js --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 5fe3c7ccd..9578861ab 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -181,11 +181,11 @@ // bitrates are sorted from lowest to the best values // so the last one has the best quality maxQuality = bitrates[bitrates.length - 1].qualityIndex; - player.setAutoSwitchQuality(false); + player.setAutoSwitchQualityFor('video', false); // set max quality player.setQualityFor("video", maxQuality); setTimeout(function() { - player.setAutoSwitchQuality(true); + player.setAutoSwitchQualityFor('video', true); }, 1000); }); From d4889465de542726dfb880dade9e8fcd67785eb8 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 16:33:04 +0300 Subject: [PATCH 09/11] Adjust ABR rules for Dash.js --- wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 9578861ab..45900ecdc 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -181,15 +181,16 @@ // bitrates are sorted from lowest to the best values // so the last one has the best quality maxQuality = bitrates[bitrates.length - 1].qualityIndex; - player.setAutoSwitchQualityFor('video', false); // set max quality player.setQualityFor("video", maxQuality); setTimeout(function() { player.setAutoSwitchQualityFor('video', true); + player.setABRStrategy('abrThroughput'); }, 1000); }); + player.setAutoSwitchQualityFor('video', false); player.initialize(media, adaptiveMedia, false); }); break; From 9d9c196fbd76883169ce1fdb810e1e901c7d4a1d Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 16:39:30 +0300 Subject: [PATCH 10/11] Adjust ABR rules for Dash.js --- .../adaptive/popcorn.HTMLAdaptiveMediaElement.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index 45900ecdc..ebb74a0fa 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -177,20 +177,10 @@ }); player.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function () { - var bitrates = player.getBitrateInfoListFor("video"), - // bitrates are sorted from lowest to the best values - // so the last one has the best quality - maxQuality = bitrates[bitrates.length - 1].qualityIndex; - // set max quality - player.setQualityFor("video", maxQuality); - setTimeout(function() { - player.setAutoSwitchQualityFor('video', true); - player.setABRStrategy('abrThroughput'); - }, 1000); - + player.setAutoSwitchQualityFor('video', true); + player.setABRStrategy('abrThroughput'); }); - player.setAutoSwitchQualityFor('video', false); player.initialize(media, adaptiveMedia, false); }); break; From 42faa53759301b01873c70191c08f9e3f3c501d6 Mon Sep 17 00:00:00 2001 From: Eugene Butusov Date: Thu, 24 Jan 2019 16:44:25 +0300 Subject: [PATCH 11/11] Adjust ABR rules for Dash.js --- .../adaptive/popcorn.HTMLAdaptiveMediaElement.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js index ebb74a0fa..a10ad89a9 100644 --- a/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js +++ b/wrappers/adaptive/popcorn.HTMLAdaptiveMediaElement.js @@ -177,10 +177,19 @@ }); player.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function () { - player.setAutoSwitchQualityFor('video', true); - player.setABRStrategy('abrThroughput'); - }); + var bitrates = player.getBitrateInfoListFor("video"), + // bitrates are sorted from lowest to the best values + // so the last one has the best quality + maxQuality = bitrates[bitrates.length - 1].qualityIndex; + // set max quality + player.setAutoSwitchQualityFor('video', false); + player.setQualityFor("video", maxQuality); + setTimeout(function() { + player.setAutoSwitchQualityFor('video', true); + player.setABRStrategy('abrThroughput'); + }, 5000); + }); player.initialize(media, adaptiveMedia, false); }); break;