Player.js 855 B

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