![](https://secure.gravatar.com/avatar/94bc91ea5673cdc6557d9fae2220c925?rating=PG&size=50&default=https%3A%2F%2Fcdn.desk.com%2Fassets%2Funknown_user_50-8ad5644bbe6b1bd7454f2ea465f782bd.png)
Start a playlist at a specific index and calling 'onPlaylistItem' only once
Lets say I have a playlist with multiple items. Whenever a user loads my page, I want to load the playlist, and I want to start the playlist at a specific index (that is maybe submitted by an query parameter).
Well, I could do this:
var player = jwplayer('player').setup({
playlist: somePlaylistArray,
...
...
}).playlistItem(someVarIndicatingTheDesiredIndex)
This works, but the problem lies in the 'onPlaylistItem' callback. This callback is now fired TWICE: once for index 0, and once for the desired index.
I have logic in this callback that I ONLY want to execute once so I'm getting into trouble with this. I don't want to use some stupid 'var firstrun = true' mechanism for obvious reasons.
Any suggestions would be appreciated,