Skip to content

Commit 8d3d720

Browse files
committed
Working cine.io implementation with timecode.
1 parent 9b24db0 commit 8d3d720

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

cine.io/player.html

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
11
<html>
22
<head>
33
<title>Cine.io Player</title>
4-
<script src='//cdn.cine.io/cineio.js'>
4+
<script src='//cdn.cine.io/cineio.js'></script>
5+
<style>
6+
#player-wrapper {
7+
width: 640px;
8+
height: 360px;
9+
}
10+
</style>
511
</head>
612
<body>
7-
<div id="player-example">
13+
<div id="player-wrapper">
14+
<div id="player-example">
15+
</div>
16+
</div>
17+
<div id="timecode-wrapper">
18+
Timecode: <div id="timecode"></div>
19+
Timestamp: <div id="timestamp"></div>
820
</div>
921
<script type="text/javascript">
1022
CineIO.init('19b899e9401d8c2198de7f56f6d066b5');
1123
var streamId = '5418ab2b5217670800fb65c3'
1224
, domId = 'player-example';
1325

26+
27+
var without = function(arr, otherArray){
28+
return arr.filter(function(item){
29+
return otherArray.indexOf(item) == -1
30+
})
31+
};
32+
var knownKeys = ["bandwidth" , "bufferfill", "duration", "height", "qualitylevel", "screenwidth", "transitioning", "width"];
33+
34+
1435
CineIO.play(streamId, domId, function(error, player) {
1536
console.log("player ready", error, player);
37+
38+
39+
player.onMeta(function(data){
40+
// console.log(without(Object.keys(data.metadata), knownKeys))
41+
// if (without(Object.keys(data.metadata), knownKeys).length > 0){
42+
// console.log(data)
43+
// }
44+
if (data.metadata.type == 'textdata') {
45+
document.getElementById('timecode').innerHTML = (data.metadata.timecode / 1000).toFixed(2);
46+
document.getElementById('timestamp').innerHTML = new Date(data.metadata.timestamp).toString();
47+
48+
console.log("TEXT", data.metadata)
49+
}
50+
});
1651
});
1752
</script>
1853
</body>

cine.io/publisher.html

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<html>
22
<head>
33
<title>Cine.io Publisher</title>
4-
<script src='//cdn.cine.io/cineio.js'>
4+
<script src='//cdn.cine.io/cineio.js'></script>
5+
<style>
6+
#publisher-example {
7+
width: 640px;
8+
height: 360px;
9+
}
10+
</style>
511
</head>
612
<body>
713
<div id="publisher-example">
814
</div>
15+
<div id="controls">
16+
<input id="btnStart" type="button" value="Start" onclick="startPublishing();" />
17+
<input id="btnStop" type="button" value="Stop" onclick="stopPublishing();" />
918
<script type="text/javascript">
1019
CineIO.init('19b899e9401d8c2198de7f56f6d066b5');
1120
var streamId = '5418ab2b5217670800fb65c3'
@@ -16,7 +25,12 @@
1625
streamId, password, domId
1726
);
1827

19-
publisher.start();
28+
function startPublishing() {
29+
publisher.start();
30+
}
31+
function stopPublishing() {
32+
publisher.stop();
33+
}
2034
</script>
2135
</body>
2236
</html>

0 commit comments

Comments
 (0)