Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play/pause buttons don't work #70

Open
RichForever opened this issue Oct 15, 2017 · 1 comment
Open

Play/pause buttons don't work #70

RichForever opened this issue Oct 15, 2017 · 1 comment

Comments

@RichForever
Copy link

I created 2 buttons for play/stop and it doesn't work. My code below

$('#vidheader').YTPlayer({ videoId: ytLink, mute: false, playButtonClass: 'YTPlayer-play', pauseButtonClass: 'YTPlayer-pause', width: $(window).width(), playerVars: { iv_load_policy: 3, modestbranding: 1, autoplay: 1, controls: 0, showinfo: 0, wmode: 'opaque', branding: 0, autohide: 0, rel: 0 } });

<div id="vid_controls" class="glb-center"> <a id="play" class="YTPlayer-play youbtn youplay" href="#"><img class="glb-max-width" src="<?php bloginfo('template_directory'); ?>/img/play-movie.png" alt=""/></a> <a class="YTPlayer-pause youbtn youpause" href="#"><img class="glb-max-width" src="<?php bloginfo('template_directory'); ?>/img/play-pause.png" alt=""/></a> </div>

when I click on any of mu buttons nothing happenes. What's wrong with my code?

@sdp49
Copy link

sdp49 commented Apr 24, 2019

Add this code after line 151:
After this code:
// Listen for Resize Event self.$window.on('resize.YTplayer' + self.ID, function() { self.resize(self); });

Add this:
$('body').on('click','.'+self.options.pauseButtonClass,function(){ self.player.pauseVideo(); $('.'+self.options.pauseButtonClass).hide() $('.'+self.options.playButtonClass).show(); }); $('body').on('click','.'+self.options.playButtonClass,function(){ self.player.playVideo(); $('.'+self.options.playButtonClass).hide(); $('.'+self.options.pauseButtonClass).show(); });

It will let you play/pause.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants