Yesterday I asked a question about running a script once a YouTube video is playing and after a lot of wrestling I figured this out.
Now the solution works in Firefox, Chrome, Safari, IE9 and IE8 but for some reason it's not working in Opera and IE7. I have very little Javascript experience so any help would be really appreciated.
I link the JS like this
<script type='text/javascript' src='http://www.example.ca/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/youtubeapi.js?ver=2011-04-28'></script>
<script type='text/javascript' src='http://www.example.ca/wp-content/plugins/slidedeck-lite-for-wordpress/lib/slidedeck.jquery.lite.js?ver=1.4.5'></script>
And within youtubeapi.js I run this
window.YTplayerState;
function onPlayerStateChange(evt) {
YTplayerState = evt.data;
}
window.YTplayerState; is an attempt to help fix the Opera/IE7 issue. Then within a pre-existing file for the SlideDeck plugin I run this
var YTplayerState;
var autoPlay = function() {
gotoNext = function() {
if (self.pauseAutoPlay === false) {
if (self.options.cycle === false && self.current == self.slides.length || YTplayerState == 1) {
self.pauseAutoPlay = true;
} else {
self.next();
}
if (YTplayerState == 1) {
self.pauseAutoPlay = true;
}
}
};
setInterval(gotoNext, self.options.autoPlayInterval);
};
Which most browser seem to be okay with, although that may just be luck, but it works. I know the issue in Opera is that YTplayerState never gets the value because if I manually change the value to one with a keypress function then it all behaves as expected.
If it's not anything with the code directly provided, are there any common quirks with Opera that I should look out for?