Player.js 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { UIPanel } from './libs/ui.js';
  5. import { APP } from './libs/app.js';
  6. function Player( editor ) {
  7. var signals = editor.signals;
  8. var container = new UIPanel();
  9. container.setId( 'player' );
  10. container.setPosition( 'absolute' );
  11. container.setDisplay( 'none' );
  12. //
  13. var player = new APP.Player();
  14. container.dom.appendChild( player.dom );
  15. window.addEventListener( 'resize', function () {
  16. player.setSize( container.dom.clientWidth, container.dom.clientHeight );
  17. } );
  18. signals.startPlayer.add( function () {
  19. container.setDisplay( '' );
  20. player.load( editor.toJSON() );
  21. player.setSize( container.dom.clientWidth, container.dom.clientHeight );
  22. player.play();
  23. } );
  24. signals.stopPlayer.add( function () {
  25. container.setDisplay( 'none' );
  26. player.stop();
  27. player.dispose();
  28. } );
  29. return container;
  30. }
  31. export { Player };