Search code examples
jwplayer

jwplayer returning function instead of player object


Here is my line of code: this.player = jwplayer(this.id);

I have two players on a page, one in an iframe. In the code I am logging the result of the jwplayer call.

The first time jwplayer('my-video-player') is called I get back an instantiated player that I can work with that contains the play() and pause() methods, etc. So far so good.

The next time when I call jwplayer('my-clip-video-player') I get back registerPlugin: ƒ. I can't figure out why a function call that creates a player object where the only parameter is a user-defined id doesn't return the same thing, a player instance.


Solution

  • When you call jwplayer('my-clip-video-player') the jwplayer call checks to make sure there is an html element with id=my-clip-video-player. I mistakenly had an id of something else so jwplayer had nothing to attach the player to. Changing the id in my markup to my-clip-video-player fixed the issue.