var sourceBuffer;
var segments = [];
var ms = new MediaSource();
var file;
var video = document.querySelector('video');
video.muted = true;
video.loop = true;
video.autoplay = true;
video.playsinline = true;
video.preload = 'auto';
video.src = window.URL.createObjectURL(ms);
ms.addEventListener('sourceopen', onMediaSourceOpen);
getData('uhd_dash.mpd');
function videoInit(initBytes) {
sourceBuffer.appendBuffer(initBytes);
video.play();
video.playbackRate = 60;
}
function onMediaSourceOpen() {
sourceBuffer = ms.addSourceBuffer('audio/mpeg'); // Major hack to trick Safari into setting m_shouldGenerateTimestamps
sourceBuffer.mode = 'sequence';
}
function getData(url) {
if (url !== "") {
url = "https://files.panomoments.com/" + url;
var xhr = new XMLHttpRequest(); // Set up xhr request
xhr.open("GET", url, true); // Open the request
xhr.responseType = "text"; // Set the type of response expected
xhr.send();
// Asynchronously wait for the data to return
xhr.onreadystatechange = function() {
if (xhr.readyState == xhr.DONE) {
var tempoutput = xhr.response;
var parser = new DOMParser(); // create a parser object
// Create an xml document from the .mpd file for searching
var xmlData = parser.parseFromString(tempoutput, "text/xml", 0);
// Get and display the parameters of the .mpd file
getFileType(xmlData);
}
}
// Report errors if they happen during xhr
xhr.addEventListener("error", function(e) {
console.log("Error: " + e + " Could not load url.");
}, false);
}
}
// retrieve parameters from our stored .mpd file
function getFileType(data) {
try {
file = data.querySelectorAll("BaseURL")[0].textContent.toString();
var rep =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.