Player.js 840 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. var Player = function ( editor ) {
  5. var signals = editor.signals;
  6. var container = new UI.Panel();
  7. container.setId( 'player' );
  8. container.setPosition( 'absolute' );
  9. container.setDisplay( 'none' );
  10. //
  11. var player = new APP.Player();
  12. window.addEventListener( 'resize', function () {
  13. player.setSize( container.dom.offsetWidth, container.dom.offsetHeight );
  14. } );
  15. signals.startPlayer.add( function () {
  16. container.setDisplay( '' );
  17. player.load( editor.toJSON() );
  18. player.setSize( container.dom.offsetWidth, container.dom.offsetHeight );
  19. player.play();
  20. container.dom.appendChild( player.dom );
  21. } );
  22. signals.stopPlayer.add( function () {
  23. container.setDisplay( 'none' );
  24. player.stop();
  25. container.dom.removeChild( player.dom );
  26. } );
  27. return container;
  28. };