-
Notifications
You must be signed in to change notification settings - Fork 1
/
content-video.php
58 lines (57 loc) · 1.98 KB
/
content-video.php
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
<?php
/**
* The template for displaying video posts
*
*/
?>
<script type="text/javascript">
// When a YT iframe is ready, this function gets fired
function onYouTubeIframeAPIReady() {
// Loop over iframes with class 'youtube'
$('iframe.youtube').each(function(i) {
var player = new YT.Player($(this).get()[0], {
events: {
'onReady': myYT.onPlayerReady,
'onStateChange': myYT.onPlayerStateChange
}
});
// Reference each iframe and store the object for retrieval
$(this).data('index', i);
myYT.players.push(player);
});
}
var myYT = {
done: false,
initFlag: true,
init: function(){
var tag, firstScriptTag;
// Insert the iframe_api script on first run
if (myYT.initFlag) {
tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
myYT.initFlag = false;
}
},
players: [],
onPlayerStateChange: function(event) {
if (event.data == YT.PlayerState.PLAYING && !myYT.done) {
setTimeout(stopVideo, 6000);
myYT.done = true;
}
function stopVideo(event) {
myYT.stopVideo(event.target);
}
},
stopVideo: function(player) {
player.stopVideo();
}
}
myYT.init();
</script>
<?php echo '<div style="background:#' . get_post_meta($post->ID, '_digitalsign_bgcolor', true) . '; height:900px; width:1920px; color:#' . get_post_meta($post->ID, '_digitalsign_pcolor', true) . ';">' ?>
<div <?php post_class( '', $post_id ); ?>>
<div style="height:900px; width:1800px; margin:-10px auto;"><iframe class="youtube" width="1800" height="900" type="text/html" src="http://www.youtube.com/embed/<?php echo get_post_meta($post->ID, '_digitalsign_ytvid', true); ?>?rel=0&controls=0&autoplay=0&modestbranding=1&showinfo=0&iv_load_policy=3&enablejsapi=1&playerapiid=<?php echo the_ID() ?>" frameborder="0" allowfullscreen></iframe></div>
</div>
</div>