var myPlayer;
function startAppInsights(){
var appInsights = window.appInsights || function (config) {
function r(config) {
t[config] = function () {
var i = arguments;
t.queue.push(function () {
t[config].apply(t, i)
})
}
}
var t = {
config: config
},
u = document,
e = window,
o = "script",
s = u.createElement(o),
i, f;
for (s.src = config.url || "//az416426.vo.msecnd.net/scripts/a/ai.0.js", u.getElementsByTagName(o)[0].parentNode
.appendChild(s), t.cookie = u.cookie, t.queue = [], i = ["Event", "Exception", "Metric", "PageView", "Trace"]; i
.length;) r("track" + i.pop());
return r("setAuthenticatedUserContext"), r("clearAuthenticatedUserContext"), config.disableExceptionTracking ||
(i = "onerror", r("_" + i), f = e[i], e[i] = function (config, r, u, e, o) {
var s = f && f(config, r, u, e, o);
return s !== !0 && t["_" + i](config, r, u, e, o), s
}), t
}({
//YOUR INSTRUMENTATION KEY HERE
instrumentationKey: "2bc01987-2273-498c-a5b7-4d60fb652c89"
});
window.appInsights = appInsights;
appInsights.trackPageView();
}
function initialize(videoContainerURL){
document.getElementById("player").innerHTML =
'
\n' +
' \n' +
'
\n' +
'\n' +
'
\n';
var myOptions = {
"nativeControlsForTouch": true,
autoplay: false,
controls: true,
width: "640",
height: "400",
poster: "",
playbackSpeed: {
enabled: true,
initialSpeed: 1.0,
speedLevels: [
{ name: "x2.0", value: 2.0 },
{ name: "x1.75", value: 1.75 },
{ name: "x1.5", value: 1.5 },
{ name: "x1.25", value: 1.25 },
{ name: "normal", value: 1.0 },
{ name: "x0.75", value: 0.75 },
{ name: "x0.5", value: 0.5 },
]
},
plugins: {
appInsights: {
"debug": false
},
frameRateTimecodeCalculator: {
"default": 30,
"timeScale": 10000000,
"dropFrame": false
}//,
// spriteTip: {
// vttUrl: videoContainerURL + "/chapters.vtt",
// }
}
};
myPlayer = amp("azuremediaplayer", myOptions);
myPlayer.src([{
src: "//" + videoContainerURL + "/video.ism/manifest",
type: "application/vnd.ms-sstr+xml"
},]);
$.ajax({
url: "//" + videoContainerURL + "/chapters.vtt",
dataType: "text",
success : function (data) {
var chapters = parseVTT(data);
}
});
return myPlayer;
}
// $(function () {
// });
function parseVTT(data){
var parts = data.split('\n')
$.each(parts, function (key, value){
//look for a time code
if(value.substring(2,3) == ':'){
var timecode = value.substring(0,10).replace(".0", ":00");
var chapterButton = "" + parts[key + 1] + "";
$("#chapters").append($(chapterButton));
}
});
return data;
}
function jumpTo(timecode) {
var absoluteTime = myPlayer.fromTimecode(timecode);
if (absoluteTime === null) {
alert("Invalid Timecode value: '" + timecode + "'");
return;
}
myPlayer.currentTime(myPlayer.fromPresentationTime(absoluteTime));
}
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};