question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'apply' of undefined

See original GitHub issue

www-widgetapi.js:48 Uncaught TypeError: Cannot read property ‘apply’ of undefined

Gets logged every refresh and play, even worse is sometimes the events don’t bind. Meaning the playerReady and playerStateChanged don’t ever get called. I am unable to see a pattern, but exactly the same code refreshed seems to sometimes result in these events not getting bound. Happens like 10% of the time.

the tags are set up like this:

<ng-youtube-embed 
    video="videoID"
    videoid="videoMainStreamer" 
    enablejsapi="true"
    onready="playerReady"
    onstatechange="playerStateChanged">
</ng-youtube-embed>

The JS is this:

    $scope.videoID = 'VJawYtS_MlE';

    $scope.playerReady = function(event) {
        console.log(event); 
    };

    $scope.playerStateChanged = function(event) {
        console.log(event);
    };

Seems to be a issue of the widgetapi, however this error is avoidable if this module would set up the onYouTubePlayerAPIReady callback in a different way.

Even worse is the events not getting bound sometimes.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Shrekiecommented, Apr 24, 2018

I think the problem lies mostly in onYouTubeIframeAPIReady not being called in certain circumstances, I would advise you to implement something like this in your module. To forcefully call the function after the iframe has been loaded.

var onLoadEvent = '';

if (!window.onNgYtIframeLoad){
    window.onNgYtIframeLoad = function(){
        window.onYouTubeIframeAPIReady();
    }
}

if(window.onNgYtIframeLoad){
    onLoadEvent = 'onLoad="onNgYtIframeLoad()"'; 
}

var iFrame = '<iframe id=" --etc--  '+ onLoadEvent +'></iframe>';

The pull request from atulingale009 includes very good improvements you should take a look at.

0reactions
ArunMichaelDsouzacommented, Nov 8, 2018

The PR has been merged. Feel free to try the new version out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'apply' of undefined · Issue #2359 - GitHub
When I use a regular browser like google chrome everything works as expected, then I used blisk I got an error saying app.js:14868...
Read more >
Redux TypeError: Cannot read property 'apply' of undefined
It checks if extension is available, if available call it and if not do nothing which means undefined . createStore method seems to...
Read more >
Error message "Cannot read property 'apply' of undefined"
When the UI Action is script is executed, this error is shown in the browser console: Uncaught TypeError: Cannot read property 'apply' of...
Read more >
Uncaught TypeError: Cannot read property 'apply' of undefined
When trying to change theme component setting, clicking the green check button produces the following error, changes are not saved (Category icons component ......
Read more >
Cannot read property 'apply' of undefined" - Forums - Liferay
RE: Cannot read property 'apply' of undefined" (Answer) ... The hover method takes 2 parameters, one for mouse over and one for mouse...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found