Skip to content

Commit

Permalink
Finally figured out how popcorn's built-in baseplayer works. Now usin…
Browse files Browse the repository at this point in the history
…g that instead of popcorn.baseplayer.js. Also trivially subclassing it as tutorialplayer.
  • Loading branch information
toolness committed Mar 10, 2012
1 parent a2a9de3 commit 61b4430
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 148 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<script src="codemirror2/mode/htmlmixed/htmlmixed.js"></script>
<script src="popcorn.js"></script>
<script src="popcorn.simplecode.js"></script>
<script src="popcorn.baseplayer.js"></script>
<script src="popcorn.undoable.js"></script>
<script src="tutorial.js"></script>
<script src="tutorial-script.js"></script>
Expand Down
4 changes: 0 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ function makePlayer(div, pop) {
});

media.addEventListener("timeupdate", function() {
if (this.currentTime >= this.duration) {
this.currentTime = this.duration;
this.pause();
}
updatePlayerUI();
});
}
Expand Down
142 changes: 0 additions & 142 deletions popcorn.baseplayer.js

This file was deleted.

20 changes: 19 additions & 1 deletion tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@
// tutorial-style interactive experiences that "script" a Webmaking
// application's behavior.

// Our tutorial player is an almost trivial subclass of Popcorn's baseplayer.
Popcorn.player("tutorialplayer", {
_setup: function() {
// By default, the baseplayer won't actually stop the video when
// the end has been reached, so we'll have to do that ourselves.
var alreadyTryingToPause = false;

this.addEventListener("timeupdate", function() {
if (!alreadyTryingToPause && this.currentTime >= this.duration) {
alreadyTryingToPause = true;
this.currentTime = this.duration;
this.pause();
alreadyTryingToPause = false;
}
});
}
});

var Tutorial = {
// Internal list of commands/events for the tutorial movie.
_commands: [],
// The Popcorn instance representing the tutorial movie.
pop: Popcorn(new Popcorn.baseplayer()),
pop: Popcorn.tutorialplayer(),
// The CodeMirror editor instance that will be manipulated over
// the course of the movie.
editor: null,
Expand Down

0 comments on commit 61b4430

Please sign in to comment.