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

Having onYouTubeIframeAPIReady function previously declared in site code #163

Closed
sturple opened this issue Feb 17, 2016 · 4 comments

Comments

@sturple
Copy link

@sturple sturple commented Feb 17, 2016

HI @pupunzi
Once you declare this callback function onYouTubeIframeAPIReady either your plugin will not work or the code you created will not work.
For example
/assets/js/script.js

function onYouTubeIframeAPIReady() {
    youtube_hp = new YT.Player('youtube_hp', {
        height: '390',
        width: '640',
        videoId: 'BLecHLDtEwA',
        events: {
          'onReady': function() {
            videoready = true;

        },
          'onStateChange': function() {}
        }
    });
}
@pupunzi

This comment has been minimized.

Copy link
Owner

@pupunzi pupunzi commented Feb 22, 2016

Hi,
Where did you find /assets/js/script.js?
I don't understand what you are referring to...
the onYouTubeIframeAPIReady() is called by the jquery.mb.YTPlayer.js file; if you overwrite that function the YTPlayer plugin is never initialized...

look at the source code line: 23
Bye,
Matteo

@sturple

This comment has been minimized.

Copy link
Author

@sturple sturple commented Feb 22, 2016

So the /assets/js/script.js is custom script for the website, which I am using the youtube api, however since you already created the onYouTubeIframeAPIReady callback function, it is impossible for me to create this function as well.

@pupunzi

This comment has been minimized.

Copy link
Owner

@pupunzi pupunzi commented Feb 22, 2016

You can just attach the function to the YTAPIReady event triggered when Youtube calls onYouTubeIframeAPIReady...

$(document).on("YTAPIReady", function(){
   youtube_hp = new YT.Player('youtube_hp', {
        height: '390',
        width: '640',
        videoId: 'BLecHLDtEwA',
        events: {
          'onReady': function() {
            videoready = true;

        },
          'onStateChange': function() {}
        }
    });
})

Bye,
Matteo

@sturple

This comment has been minimized.

Copy link
Author

@sturple sturple commented Feb 22, 2016

ah, yes i see that now, thanks for the help.

@sturple sturple closed this Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.