-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the way of loading players engine and default versions (#34)
- Loading branch information
1 parent
41c68cb
commit d3a5fcf
Showing
4 changed files
with
49 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,8 @@ | |
// Do NOT Change order of script sources! | ||
var scriptSources = [ | ||
// Required by Shaka Player to support MPEG-2 TS | ||
"https://cdnjs.cloudflare.com/ajax/libs/mux.js/5.10.0/mux.min.js", | ||
"https://cdn.jsdelivr.net/npm/[email protected]", | ||
"https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js", | ||
"src/engineChange.js", | ||
"js_mse_eme/harness/util.js", | ||
"js_mse_eme/harness/constants.js", | ||
"js_mse_eme/harness/key.js", | ||
|
@@ -50,7 +50,6 @@ | |
"src/common.js", | ||
"mediaStreams.js", | ||
"src/mvtTest.js", | ||
"src/engineChange.js", | ||
"src/profiles.js", | ||
"src/engines.js", | ||
"src/mediaTests.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,22 @@ var EngineVersions = { | |
versions: { | ||
"2.9.3": ["https://cdn.dashjs.org/v2.9.3/dash.all.min.js", "https://cdn.dashjs.org/v2.9.3/dash.mss.min.js"], | ||
"3.1.1": ["https://cdn.dashjs.org/v3.1.1/dash.all.min.js", "https://cdn.dashjs.org/v3.1.1/dash.mss.min.js"], | ||
"4.4.0": ["https://cdn.dashjs.org/v4.4.0/dash.all.min.js", "https://cdn.dashjs.org/v4.4.0/dash.mss.min.js"], | ||
latest: ["https://cdn.dashjs.org/latest/dash.all.min.js", "https://cdn.dashjs.org/latest/dash.mss.min.js"], | ||
}, | ||
name: "Dash.JS", | ||
defaultVersion: "latest", | ||
defaultVersion: "4.4.0", | ||
}, | ||
hlsjs: { | ||
versions: { | ||
"1.0.0": ["https://cdn.jsdelivr.net/npm/[email protected]"], | ||
"1.1.5": ["https://cdn.jsdelivr.net/npm/[email protected]"], | ||
"1.2.1": ["https://cdn.jsdelivr.net/npm/[email protected]"], | ||
"1.2.9": ["https://cdn.jsdelivr.net/npm/[email protected]"], | ||
"1.3.0": ["https://cdn.jsdelivr.net/npm/[email protected]"], | ||
}, | ||
name: "HLS.js", | ||
defaultVersion: "1.3.0", | ||
}, | ||
}; | ||
|
||
|
@@ -54,38 +66,40 @@ function getQueryVariable(variable) { | |
|
||
function loadStoredEngine() { | ||
for (var engineId in EngineVersions) { | ||
var engine = EngineVersions[engineId]; | ||
var queryVariable = getQueryVariable("engine_" + engineId); | ||
if (window.location.search.includes(engineId)) { | ||
var engine = EngineVersions[engineId]; | ||
var queryVariable = getQueryVariable("engine_" + engineId); | ||
|
||
if (queryVariable) { | ||
// if engine version is provided but it does not exist in 'EngineVersions', replace it to the default value: | ||
if (engine.versions[queryVariable] === undefined) { | ||
console.warn( | ||
`${engineId} player version '${queryVariable}' is not available, it has been set to default: '${engine.defaultVersion}'` | ||
); | ||
window.history.pushState("", "", window.location.search.replace(`&engine_${engineId}=${queryVariable}`, "")); | ||
// remove version parameter from the url if the provided version is the default one: | ||
} else if (queryVariable === engine.defaultVersion) { | ||
window.history.pushState("", "", window.location.search.replace(`&engine_${engineId}=${queryVariable}`, "")); | ||
} else { | ||
engine.defaultVersion = queryVariable; | ||
if (queryVariable) { | ||
// if engine version is provided but it does not exist in 'EngineVersions', replace it to the default value: | ||
if (engine.versions[queryVariable] === undefined) { | ||
console.warn( | ||
`${engineId} player version '${queryVariable}' is not available, it has been set to default: '${engine.defaultVersion}'` | ||
); | ||
window.history.pushState("", "", window.location.search.replace(`&engine_${engineId}=${queryVariable}`, "")); | ||
// remove version parameter from the url if the provided version is the default one: | ||
} else if (queryVariable === engine.defaultVersion) { | ||
window.history.pushState("", "", window.location.search.replace(`&engine_${engineId}=${queryVariable}`, "")); | ||
} else { | ||
engine.defaultVersion = queryVariable; | ||
} | ||
} | ||
} | ||
console.log("Engine : " + engine.name + " : " + engine.defaultVersion); | ||
console.log("Engine : " + engine.name + " : " + engine.defaultVersion); | ||
|
||
var scriptSources = engine.versions[engine.defaultVersion]; | ||
(function loadNextScript() { | ||
if (scriptSources.length) { | ||
var script = document.createElement("script"); | ||
script.src = scriptSources[0]; | ||
script.async = script.defer = true; | ||
script.onload = function () { | ||
scriptSources.shift(); | ||
loadNextScript(); | ||
}; | ||
document.head.appendChild(script); | ||
} | ||
})(); | ||
var scriptSources = engine.versions[engine.defaultVersion]; | ||
(function loadNextScript() { | ||
if (scriptSources.length) { | ||
var script = document.createElement("script"); | ||
script.src = scriptSources[0]; | ||
script.async = script.defer = true; | ||
script.onload = function () { | ||
scriptSources.shift(); | ||
loadNextScript(); | ||
}; | ||
document.head.appendChild(script); | ||
} | ||
})(); | ||
} | ||
} | ||
} | ||
|
||
|