Skip to content

Instantly share code, notes, and snippets.

@alexeypegov
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexeypegov/76b22e60a70402bc8e4f to your computer and use it in GitHub Desktop.
Save alexeypegov/76b22e60a70402bc8e4f to your computer and use it in GitHub Desktop.
Embedding Animatron Player
<html>
<head>
<!-- Animatron Player Bundle -->
<script type="text/javascript" src="http://player-dev.animatron.com/latest/bundle/animatron.js"></script>
</head>
<body>
<!-- Canvas element for Player to draw into -->
<canvas id="anm"></canvas>
<!-- Custom controls -->
<div id="sections">
<div class="section">
Section 1.
<a href="javascript:play(0)">Play</a> | <!-- call play(0) to start playing from the beginning (0 sec) -->
<a href="javascript:pause();">Pause</a></div> <!-- pause control -->
<div class="section">
Section 2.
<a href="javascript:play(10)">Play</a> | <!-- call play(10) to start playing from the beginning of second scene (10 secs) -->
<a href="javascript:pause();">Pause</a></div> <!-- pause control -->
</div>
<!-- Player initialization and project loading -->
<script type="text/javascript">
// play function
function play(time) {
var player = window.player;
player.stop(); // ensure player is stopped
player.play(time); // start playing from the specified time
}
// pause player
function pause() {
window.player.pause();
}
// initialize player and load project data
window.player = anm.Player.forSnapshot("anm",
/* Use your project ID from the Publish HTML dialog here */
"http://snapshots.animatron.com/8e188b4e170e60300117ce70fa76ab76-v1.1",
anm.createImporter('animatron'));
window.player.on(anm.C.S_LOAD, function(_player) {
// add something you need to be run as soon as project will be loaded
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment