forked from ooyala/html5-skin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iframe.html
96 lines (89 loc) · 3.51 KB
/
iframe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html style="padding:0; margin:0; width:100%; height:100%; overflow:hidden">
<head>
<meta charset="utf-8">
<script src="//player.ooyala.com/static/v4/production/latest/core.min.js"></script>
<script src="//player.ooyala.com/static/v4/production/latest/video-plugin/main_html5.min.js"></script>
<script src="//player.ooyala.com/static/v4/production/latest/video-plugin/osmf_flash.min.js"></script>
<script src="//player.ooyala.com/static/v4/production/latest/video-plugin/bit_wrapper.min.js"></script>
<script src="//player.ooyala.com/static/v4/production/latest/skin-plugin/html5-skin.min.js"></script>
<link rel="stylesheet" href="//player.ooyala.com/static/v4/production/latest/skin-plugin/html5-skin.min.css"/>
</head>
<body style="padding:0; margin:0; width:100%; height:100%; overflow:hidden">
<div id='container' style='width:100%; height:100%;'></div>
<script>
function queryStringToJSON(query) {
var setValue = function(root, path, value) {
if (path.length > 1){
var dir = path.shift();
if (typeof root[dir] == 'undefined') {
root[dir] = path[0] == '' ? [] : {};
}
arguments.callee(root[dir], path, value);
} else {
if (root instanceof Array) {
root.push(value);
} else {
root[path] = value;
}
}
};
var nvp = query.split('&');
var data = {};
for (var i = 0 ; i < nvp.length ; i++) {
var pair = nvp[i].split('=');
if (!Array.isArray(pair) || pair.length != 2) {
continue;
}
var name = decodeURIComponent(pair[0]);
var value = decodeURIComponent(pair[1]);
var path = name.match(/(^[^\[]+)(\[.*\]$)?/);
if (!Array.isArray(path) || path.length < 2) {
continue;
}
var first = path[1];
if (path[2]) {
//case of 'array[level1]' || 'array[level1][level2]'
path = path[2].match(/(?=\[(.*)\]$)/)[1].split('][')
} else {
//case of 'name'
path = [];
}
path.unshift(first);
setValue(data, path, value);
}
return data;
}
// ATTN: embedToken parameter in URL should be url-encoded! For example:
// embedToken="http://player.ooyala.com/sas/embed_token/AAA/BBB?account_id=CCC&api_key=DDD&expires=EEE&signature=FFF"
// should be provided as:
// embedToken=%22http%3A%2F%2Fplayer.ooyala.com%2Fsas%2Fembed_token%2FAAA%2FBBB%3Faccount_id%3DCCC%26api_key%3DDDD%26expires%3DEEE%26signature%3DFFF%22
var playerParams = queryStringToJSON(window.location.search.substring(1));
var skin = {
config: playerParams["skin.config"] || "",
inline: {
shareScreen: {
embed: {
source: "<iframe width='640' height='480' frameborder='0' allowfullscreen src='//player.ooyala.com/static/v4/production/latest/skin-plugin/iframe.html?ec=<ASSET_ID>&pbid=<PLAYER_ID>&pcode=<PUBLISHER_ID>'></iframe>"
}
}
}
};
playerParams["playerBrandingId"] = playerParams.pbid;
playerParams["skin"] = skin;
delete playerParams.pbid;
delete playerParams["skin.config"];
// Parse docUrl
if (!playerParams.docUrl) {
if (document.referrer) {
playerParams["docUrl"] = document.referrer;
} else {
console.log("iframe.html - document.referrer was not set");
}
}
OO.ready(function() {
window.pp = OO.Player.create('container', playerParams.ec, playerParams);
});
</script>
</body>
</html>