File: /home/httpd/html/baretube.com/media/cors_fallback.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return results[2].replace(/\+/g, " ");
}
(function() {
var video_tag = document.createElement("dl8-video");
var base64data = decodeURIComponent(getParameterByName('q'));
//console.log(base64data);
//var params = document.location.search.slice(1).split("&");
var params = base64data.slice(1).split("&");
var source_params = {};
var source_tags = [];
var poster_image = "",
main_title = "",
video_format = "",
brand_url = "",
author = "",
cors_custom_cta = "Play Video",
cors_custom_message = "Since you are using an Apple Device or Browser a new window will need to open to play back this video.",
cors_custom_heading = "";
params.map(function(e, i) {
//e = decodeURIComponent(e);
if (e.match("url_") || e.match("title_")) {
var id = e.match(/_(\d+)/g)[0].replace("_", "");
var key = e.match("url") ? "url" : "title";
var value2 = e.split("=")[1];
var value = "https://"+decodeURIComponent(value2);
if (source_params[id] == undefined) {
createNewSourceParamObject(id, key, value);
} else {
addNewPropertyTo(id, key, value);
}
} else if (e.match("format")) {
video_format = e.split("=")[1]
} else if (e.match("main_title")) {
main_title = e.split("=")[1]
} else if (e.match("poster_image")) {
poster_image = e.split("=")[1]
} else if (e.match("author")) {
author = e.split("=")[1]
} else if (e.match("brand_url")) {
brand_url = e.split("=")[1];
} else if(e.match("cors_custom_cta")) {
cors_custom_cta = e.split("=")[1];
} else if(e.match("cors_custom_message")) {
cors_custom_message = e.split("=")[1];
} else if(e.match("cors_custom_heading")) {
cors_custom_heading = e.split("=")[1];
}
});
video_tag.title = main_title;
var poster = document.createAttribute("poster");
poster.value = poster_image;
video_tag.attributes.setNamedItem(poster);
var author_attribute = document.createAttribute("author");
author_attribute.value = author;
video_tag.attributes.setNamedItem(author_attribute);
var format_attribute = document.createAttribute("format");
format_attribute.value = video_format;
video_tag.attributes.setNamedItem(format_attribute);
var display_mode = document.createAttribute("display-mode");
display_mode.value = "inline";
video_tag.attributes.setNamedItem(display_mode);
var width = document.createAttribute("width");
width.value = "100%";
video_tag.attributes.setNamedItem(width);
var cors_custom_cta_attribute = document.createAttribute("cors-custom-cta");
cors_custom_cta_attribute.value = cors_custom_cta;
video_tag.attributes.setNamedItem(cors_custom_cta_attribute);
var cors_custom_message_attribute = document.createAttribute("cors-custom-message");
cors_custom_message_attribute.value = cors_custom_message;
video_tag.attributes.setNamedItem(cors_custom_message_attribute);
var cors_custom_heading_attribute = document.createAttribute("cors-custom-heading");
cors_custom_heading_attribute.value = cors_custom_heading;
video_tag.attributes.setNamedItem(cors_custom_heading_attribute);
for (o in source_params) {
var new_source = document.createElement("source");
var thisObject = source_params[o];
new_source.src = thisObject.url;
var type = thisObject.url.match("webm") ? "webm" : "mp4";
new_source.type = "video/" + type;
var quality_attr = document.createAttribute("quality");
quality_attr.value = thisObject.title;
new_source.attributes.setNamedItem(quality_attr);
source_tags.push(new_source)
video_tag.appendChild(new_source);
}
document.addEventListener("DOMContentLoaded", function(event) {
var content = document.querySelectorAll("section.content")[0];
if(!content){
content = document.createElement("section");
content.classList.add("content");
content.appendChild(video_tag);
document.getElementsByTagName("body")[0].appendChild(content);
} else {
content.appendChild(video_tag);
}
})
function createNewSourceParamObject(id, key, value) {
if (key == "url") {
source_params[id] = {
url: value
};
} else if (key == "title") {
source_params[id] = {
title: value
}
}
}
function addNewPropertyTo(id, key, value) {
if (key == "url") {
source_params[id][key] = value
} else if (key == "title") {
source_params[id][key] = value
}
}
})();
</script>
<title>VR Player - Sitename</title>
</head>
<body>
<style media="screen">
section.content {
max-width: 800px;
margin: auto;
}
</style>
<!-- <section class="content"></section> -->
<script src="{INSERT YOUR DELIGHT VR JAVASCRIPT HERE}"></script>
</body>
</html>