Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $('#home').YTPlayer({
- fitToBackground: true,
- videoId: 'o5UFpWgV30o',
- mute: false,
- callback: function(){
- //stop video when offsceen
- var wind = $(window);
- var height = wind.height();
- var yt = $('#home').data("ytPlayer").player;
- wind.on("scroll", function(){
- //check if the user scrolled offscreen -> the size of the window
- var scroll = $(this).scrollTop();
- if(scroll > height){
- yt.pauseVideo();
- }else{
- yt.playVideo();
- }
- });
- wind.on("resize", function(){
- height = wind.height(); //update height when the window is resized
- });
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement