You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
CoffeeScript
59 lines
1.5 KiB
CoffeeScript
class AsciiIo.PlayerView extends Backbone.View
|
|
|
|
initialize: (options) ->
|
|
@movie = new AsciiIo.Movie(@model, options.autoPlay)
|
|
@movie.load()
|
|
|
|
@terminalView = new AsciiIo.TerminalView(
|
|
cols: this.options.cols
|
|
lines: this.options.lines
|
|
)
|
|
|
|
@vt = new AsciiIo.VT(options.cols, options.lines, @terminalView)
|
|
|
|
@createChildViews()
|
|
@bindEvents()
|
|
|
|
createChildViews: ->
|
|
@$el.append(@terminalView.$el)
|
|
@terminalView.afterInsertedToDom()
|
|
@terminalView.showLoadingIndicator()
|
|
|
|
@hudView = new AsciiIo.HudView()
|
|
@$el.append(@hudView.$el)
|
|
|
|
bindEvents: ->
|
|
@terminalView.on 'terminal-click', =>
|
|
@movie.togglePlay()
|
|
|
|
@hudView.on 'hud-play-click', =>
|
|
@movie.togglePlay()
|
|
|
|
@hudView.on 'hud-seek-click', (percent) =>
|
|
@movie.seek(percent)
|
|
|
|
@movie.on 'movie-loaded', (asciicast) =>
|
|
@terminalView.hideLoadingIndicator()
|
|
@hudView.setDuration(asciicast.get('duration'))
|
|
unless @options.autoPlay
|
|
@terminalView.showToggleOverlay()
|
|
|
|
@movie.on 'movie-playback-paused', =>
|
|
@hudView.onPause()
|
|
|
|
@movie.on 'movie-playback-resumed', =>
|
|
@hudView.onResume()
|
|
|
|
@movie.on 'movie-time', (time) =>
|
|
@hudView.updateTime(time)
|
|
|
|
@movie.on 'movie-frame', (frame) =>
|
|
@vt.feed(frame)
|
|
|
|
@movie.on 'movie-awake', (frame) =>
|
|
@terminalView.restartCursorBlink()
|
|
|
|
@movie.on 'movie-finished', =>
|
|
@terminalView.stopCursorBlink()
|
|
@hudView.setProgress(100)
|