Skip to content

Commit

Permalink
Throw an Error if currentTime can't be set after loading. (dseif#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyBanks committed Jun 12, 2012
1 parent b145498 commit 7c8b560
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ addEventListener( "DOMContentLoaded", function() {

// Initialization to take place after media (and Butter)? is ready.
function initAfterMediaReady () {
var duration = popcorn.duration(),
originalTime = popcorn.currentTime(),
targetTime = 0;

if ( originalTime === targetTime ) {
targetTime += popcorn.duration() / 2;
}

popcorn.currentTime( targetTime );

if ( popcorn.currentTime() === originalTime ) {
throw new Error( "Calling popcorn.currentTime(x) did not affect the value of popcorn.currentTime()." );
}

console.log( "Media ready, continuing initialization." );

if ( inButter ) {
Expand Down

0 comments on commit 7c8b560

Please sign in to comment.