-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path2015-11-10-dynamic-insertion.html
More file actions
186 lines (159 loc) · 6.42 KB
/
2015-11-10-dynamic-insertion.html
File metadata and controls
186 lines (159 loc) · 6.42 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
layout: post
title: Dynamic insertion
weight: 3
category: player-api
categoryItemType: example
categoryItemIsShown: 1
categoryItemWidth:
categoryItemDescription:
categoryItemLabel:
---
<article class="row">
<section>
<div style="padding-bottom:56.25%; position:relative; display:block; width: 100%">
<iframe src="https://video.ibm.com/embed/1524?html5ui" id="FrameAlpha" width="100%" height="100%" allowfullscreen webkitallowfullscreen style="border: 0 transparent none; position:absolute; top:0; left: 0"></iframe>
</div>
<div class="panel clear">
<div id="PlayAlpha" class="button button-icon control-play"><i class="glyphicon icon-play-2"></i>Play</div>
<div id="PauseAlpha" class="button button-icon control-pause"><i class="glyphicon icon-pause-2"></i>Pause</div>
<div class="pull-right" id="StatusAlpha">
<span style="display: none;" class="st-live label status">LIVE</span>
<span style="display: none;" class="st-offline status label">OFFLINE</span>
<span style="display: none;" class="st-playing label">PLAYING</span>
<span style="display: none;" class="st-ended label">ENDED</span>
</div>
</div>
</section>
<section>
<div style="padding-bottom:56.25%; position:relative; display:block; width: 100%" id="Beta">
</div>
<div class="panel clear">
<div id="PlayBeta" class="button button-icon control-play"><i class="glyphicon icon-play-2"></i>Play</div>
<div id="PauseBeta" class="button button-icon control-pause"><i class="glyphicon icon-pause-2"></i>Pause</div>
<div class="pull-right" id="StatusBeta">
<span style="display: none;" class="st-live label status">LIVE</span>
<span style="display: none;" class="st-offline status label">OFFLINE</span>
<span style="display: none;" class="st-playing label">PLAYING</span>
<span style="display: none;" class="st-ended label">ENDED</span>
</div>
</div>
</section>
<section>
<div id="Gamma">
<div id="InsertGamma" class="button">Insert embed</div>
</div>
<div class="panel clear hidden">
<div id="PlayGamma" class="button button-icon control-play"><i class="glyphicon icon-play-2"></i>Play</div>
<div id="PauseGamma" class="button button-icon control-pause"><i class="glyphicon icon-pause-2"></i>Pause</div>
<div class="pull-right" id="StatusGamma">
<span style="display: none;" class="st-live label status">LIVE</span>
<span style="display: none;" class="st-offline status label">OFFLINE</span>
<span style="display: none;" class="st-playing label">PLAYING</span>
<span style="display: none;" class="st-ended label">ENDED</span>
</div>
</div>
</section>
</article>
<style>
.label[class*="st-"] {
padding: 0 .4rem;
font-size: 1rem;
text-transform: uppercase;
font-weight: 700;
line-height: 1.7rem;
border-radius: 2px;
display: inline-block;
}
.label.st-live {
background-color: #ff3d23;
color: white;
}
.label.st-offline {
background-color: #9cacbc;
color: white;
}
.label.st-playing {
background-color: #539eec;
color: white;
}
.label.st-ended {
background-color: #e166b7;
color: white;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('#Beta').html('<iframe src="https://www.ustream.tv/embed/6540154?html5ui" ' +
'id="FrameBeta" ' +
'width="100%" ' +
'height="100%" ' +
'allowfullscreen webkitallowfullscreen style="border: 0 transparent none; position:absolute; top:0; left:0"></iframe>');
/* create player instances */
var alpha = UstreamEmbed("FrameAlpha"),
beta = UstreamEmbed("FrameBeta"),
gamma;
/* bind controls to buttons */
$('#PlayAlpha').on('click', function (e) { e.preventDefault(); e.stopPropagation(); alpha.callMethod('play'); });
$('#PlayBeta').on('click', function (e) { e.preventDefault(); e.stopPropagation(); beta.callMethod('play'); });
$('#PauseAlpha').on('click', function (e) { e.preventDefault(); e.stopPropagation(); alpha.callMethod('pause'); });
$('#PauseBeta').on('click', function (e) { e.preventDefault(); e.stopPropagation(); beta.callMethod('pause'); });
/*
event handler for events received from the embed iframe
*/
var onEmbedEvent = function (id, event, data) {
var parent = $('#' + id);
switch (event) {
case "live":
parent.find('.st-live').show();
parent.find('.st-offline').hide();
break;
case "offline":
parent.find('.st-offline').show();
parent.find('.st-live').hide();
break;
case "playing":
if (data) {
parent.find('.st-playing').show()
} else {
parent.find('.st-playing').hide();
}
break;
case "finished":
parent.find('.st-ended').show();
break;
}
}
/*
adding event handlers, one by one
*/
alpha.addListener('live', $.proxy(onEmbedEvent, null, 'StatusAlpha'));
alpha.addListener('offline', $.proxy(onEmbedEvent, null, 'StatusAlpha'));
alpha.addListener('playing', $.proxy(onEmbedEvent, null, 'StatusAlpha'));
alpha.addListener('finished', $.proxy(onEmbedEvent, null, 'StatusAlpha'));
beta.addListener('live', $.proxy(onEmbedEvent, null, 'StatusBeta'));
beta.addListener('offline', $.proxy(onEmbedEvent, null, 'StatusBeta'));
beta.addListener('playing', $.proxy(onEmbedEvent, null, 'StatusBeta'));
beta.addListener('finished', $.proxy(onEmbedEvent, null, 'StatusBeta'));
$('#InsertGamma').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
var gammaHolder = $('#Gamma');
gammaHolder.attr('style','padding-bottom:56.25%; position:relative; display:block; width: 100%');
var gammaFrame = $('<iframe src="https://www.ustream.tv/embed/recorded/24364591?html5ui" ' +
'id="FrameGamma" ' +
'width="100%" height="100%" ' +
'allowfullscreen webkitallowfullscreen style="border: 0 transparent none; position:absolute; top:0; left: 0"></iframe>'
);
gammaHolder.append(gammaFrame);
gammaHolder.next().removeClass('hidden');
gamma = UstreamEmbed(gammaFrame[0]);
$('#PlayGamma').on('click', function (e) { e.preventDefault(); e.stopPropagation(); gamma.callMethod('play'); });
$('#PauseGamma').on('click', function (e) { e.preventDefault(); e.stopPropagation(); gamma.callMethod('pause'); });
gamma.addListener('live', $.proxy(onEmbedEvent, null, 'StatusGamma'));
gamma.addListener('offline', $.proxy(onEmbedEvent, null, 'StatusGamma'));
gamma.addListener('playing', $.proxy(onEmbedEvent, null, 'StatusGamma'));
gamma.addListener('finished', $.proxy(onEmbedEvent, null, 'StatusGamma'));
})
});
</script>