Last active
August 29, 2015 13:57
-
-
Save alishalisha/9769877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generate a random integer to add on to our unique namespace parameter | |
ad.enable_log = true; | |
var videoNamespace = ad.slug.toUpperCase() | |
var videoPlaying = false; | |
var ooyalaScript = document.createElement('script'); | |
ooyalaScript.src = 'http://player.ooyala.com/v3/8c6bc9de76f3488cb79e4080758a0db6?namespace=' + videoNamespace; | |
var firstScriptTag = document.getElementsByTagName('script')[0]; | |
firstScriptTag.parentNode.insertBefore(ooyalaScript, firstScriptTag); | |
$fishtankVideo = jQuery('#fishtank-video'); | |
$fishtankVideo.hide(); | |
var playFishtankVideo = function(videoCode) { | |
if (videoPlaying) { return; } | |
$fishtankVideo.show(); | |
var namespaceConstant; | |
eval("namespaceConstant = " + videoNamespace); | |
var ooyalaVideoPlayer = namespaceConstant.Player.create('fishtank-video', videoCode, { | |
autoplay: '1', | |
onCreate: function(player) { | |
player.mb.subscribe('played','hiAlisha', function(eventName) { | |
player.destroy(); | |
jQuery('#fishtank-video').hide(); | |
videoPlaying = false; | |
}); | |
player.mb.subscribe('playing', 'hiAlisha', function(eventName) { | |
ad.engage('video-play'); | |
}); | |
} | |
}); | |
videoPlaying = true; | |
} | |
$('#fishtank-play').click(function(){ | |
playFishtankVideo('dlZzY5bDqqIBZx7-FFuXeWYIhy4GRTr-'); // You need to update this Embed Code | |
return false; // don't bubble | |
}); | |
// This is going to watch if we are in the viewport, and start playing if we are. | |
// if we are not in the viewport it will call itself to check in another second. | |
var playIfInViewPort = function(){ | |
if(Hymnal.util.inViewport(ad.getElement())){ | |
playFishtankVideo('dlZzY5bDqqIBZx7-FFuXeWYIhy4GRTr-'); // You need to update this Embed Code | |
} else { | |
setTimeout(playIfInViewPort,1000); | |
} | |
} | |
// playIfInViewPort(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment