Merge branch 'seeking'

* seeking:
  Progress arrow with proper length
  Hacky version of "seeking"
  Seeking prototype
openid
Marcin Kulik 13 years ago
commit 6b8a80c823

@ -4,6 +4,7 @@ class AsciiIo.HudView extends Backbone.View
events:
'click .toggle': 'togglePlay'
'click .progress span': 'seek'
initialize: (options) ->
@duration = undefined
@ -31,6 +32,11 @@ class AsciiIo.HudView extends Backbone.View
togglePlay: ->
@trigger('hud-play-click')
seek: (e) ->
index = $(e.target).index()
percent = 100 * index / (@progressWidth - 2)
@trigger('hud-seek-click', percent)
onPause: ->
@$('.toggle').addClass('paused')
@ -41,7 +47,7 @@ class AsciiIo.HudView extends Backbone.View
@$('.time').html(@formattedTime(time))
if @duration
progress = 100 * time / 1000 / @duration
progress = Math.round(100 * time / 1000 / @duration)
@setProgress progress
setProgress: (percent) ->
@ -51,7 +57,10 @@ class AsciiIo.HudView extends Backbone.View
if arrowWidth != @lastArrowWidth
arrow = '='.times(arrowWidth) + '>'
filler = ' '.times(@progressWidth - 3 - arrowWidth)
@$('.progress').text('[' + arrow + filler + ']')
bar = arrow + filler
chars = _(bar.split('')).map (c) -> "<span>#{c}</span>"
html = chars.join('')
@$('.progress').html('[' + html + ']')
@lastArrowWidth = arrowWidth
formattedTime: (time) ->

@ -113,12 +113,41 @@ class AsciiIo.Movie
!@isPlaying() and @isLoaded() and @frameNo >= @timing().length
seek: (percent) ->
@pause()
@stop()
@rewindTo(percent)
@play()
@resume()
rewindTo: (percent) ->
# TODO
duration = @model.get('duration')
requestedTime = duration * percent / 100
frameNo = 0
time = 0
totalCount = 0
delay = undefined
count = undefined
while time < requestedTime
[delay, count] = @timing()[frameNo]
if time + delay >= requestedTime
break
time += delay
totalCount += count
frameNo += 1
@frameNo = frameNo
@completedFramesTime = time * 1000
@dataIndex = totalCount
data = @data().slice(0, totalCount)
@trigger('movie-reset')
@trigger('movie-frame', data)
@lastFrameAt = @now()
wait = requestedTime - time
@totalFrameWaitTime = wait * 1000
startTimeReporter: ->
@timeReportId = setInterval(
@ -181,7 +210,6 @@ class AsciiIo.Movie
true
else
@playing = false
@stopTimeReporter()
@trigger('movie-finished')
if @options.benchmark

@ -61,6 +61,9 @@ class AsciiIo.PlayerView extends Backbone.View
@movie.on 'movie-time', (time) =>
@hudView.updateTime(time)
@movie.on 'movie-reset', =>
@vt.reset()
@movie.on 'movie-frame', (frame) =>
@vt.feed(frame)

@ -2,6 +2,9 @@ class AsciiIo.VT
constructor: (@cols, @lines, @view) ->
@sgrInterpreter = new AsciiIo.SgrInterpreter()
@reset()
reset: ->
@data = ''
@resetTerminal()

@ -143,6 +143,11 @@ $color5: #EDC951;
.progress {
color: black;
cursor: pointer;
span:hover {
background-color: #777;
}
}
.time {

Loading…
Cancel
Save