Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="http://www.youtube.com/player_api"></script>
- <div id="player"></div>
- <script>
- var player;
- function onYouTubePlayerAPIReady() {
- player = new YT.Player('player', {
- playerVars: {
- 'autoplay': 1,
- 'controls': 0,
- 'autohide': 1,
- 'wmode': 'opaque',
- 'showinfo': 1,
- 'mute': 1,
- 'loop': 1,
- //'start': 15,
- //'end': 110,
- 'list': 'PLZ4N99MMo_3KNAMAPvfxYW68WQJ1jBZ9k',
- },
- height: '0',
- width: '0',
- videoId: '7e4VZfS5ElY',
- events: {
- 'onReady': onPlayerReady
- }
- });
- }
- function onPlayerReady(event) {
- event.target.mute();
- $('#text').fadeIn(400);
- //why this? Well, if you want to overlay text on top of your video, you
- //will have to fade it in once your video has loaded in order for this
- //to work in Safari, or your will get an origin error.
- }
- //this pauses the video when it's out of view, just wrap your video in .m-//video
- $(window).scroll(function() {
- var hT = $('.m-video').height(),
- wS = $(this).scrollTop();
- if (wS > hT) {
- player.pauseVideo();
- }
- else {
- player.playVideo();
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment