Created
June 12, 2017 22:02
-
-
Save samueleresca/595a0764f5b110b3c56827528e8de09e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function play(movieId, cancelButton, callback) { | |
var movieTicket, | |
playError, | |
tryFinish = function () { | |
if (playError) { | |
callback(null, playError); | |
} | |
else if (movieTicket && player.initialized) { | |
callback(null, ticket); | |
} | |
}; | |
cancelButton.addEventListener("click", function () { playError = "cancel"; }); | |
if (!player.initialized) { | |
player.init(function () { | |
playError = error; | |
tryFinish(); | |
}); | |
} | |
authorizeMovie(movieId, function (error, ticket) { | |
playError = error; | |
movieTicket = ticket; | |
tryFinish(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment