Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

[#960183] Ensure we remove ready callbacks when they are called. #368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions wrappers/null/popcorn.HTMLNullVideoElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
self._util.type = "NullVideo";

function addPlayerReadyCallback( callback ) {
playerReadyCallbacks.unshift( callback );
playerReadyCallbacks.push( callback );
}

function onPlayerReady( ) {
Expand All @@ -128,10 +128,9 @@
impl.readyState = self.HAVE_ENOUGH_DATA;
self.dispatchEvent( "canplaythrough" );

var i = playerReadyCallbacks.length;
while( i-- ) {
playerReadyCallbacks[ i ]();
delete playerReadyCallbacks[ i ];
while( playerReadyCallbacks.length ) {
playerReadyCallbacks[ 0 ]();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's shift first:

var cb = playerReadyCallbacks.shift();
cb();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to declare the callback at the top of this function scope, but otherwise, no isses.

haha, or playerReadyCallbacks.shift()();

playerReadyCallbacks.shift();
}

// Auto-start if necessary
Expand Down