# HG changeset patch # User Drew Perttula # Date 1465075438 0 # Node ID 2d77dc9436c3f0c5195a11da48f478917cc74a0a # Parent 3843f6bd0460c2cbfd6121d831707f0869fbe98e music drives cursor Ignore-this: ffa7a9a94084bb8feab6d04e888fb3f6 diff -r 3843f6bd0460 -r 2d77dc9436c3 light9/web/light9-music.coffee --- a/light9/web/light9-music.coffee Sat Jun 04 20:43:31 2016 +0000 +++ b/light9/web/light9-music.coffee Sat Jun 04 21:23:58 2016 +0000 @@ -5,25 +5,56 @@ is: "light9-music", properties: status: { type: String, notify: true } + statusTitle: { type: String, notify: true } + turboSign: { type: String, notify: true } + duration: { type: Number, notify: true } playing: { type: Boolean, notify: true } song: { type: String, notify: true } t: { type: Number, notify: true } + ready: -> + @turboUntil = 0 @$.getTime.addEventListener('response', @onResponse.bind(@)) @$.getTime.addEventListener 'error', (e) => req = @$.getTime.lastRequest - @status = "GET "+req.url+ " -> " + req.status + " " + req.statusText + @status = "✘" + @statusTitle = "GET "+req.url+ " -> " + req.status + " " + req.statusText setTimeout(@poll.bind(@), 2000) @poll() + setInterval(@estimateTimeLoop.bind(@), 50) + + estimateTimeLoop: -> + if @playing + @t = @remoteT + (Date.now() - @remoteAsOfMs) / 1000 + else + @t = @remoteT + poll: -> @$.getTime.generateRequest() - @status = "poll" + @status = "♫" onResponse: -> - @status = "ok" - setTimeout(@poll.bind(@), 1000) + @status = " " r = @$.getTime.lastResponse + now = Date.now() + if !r.playing && r.t != @remoteT + # likely seeking in another tool + @turboUntil = now + 1000 + if now < @turboUntil + @turboSign = "⚡" + delay = 20 + else + @turboSign = " " + delay = 700 + + setTimeout(@poll.bind(@), delay) @duration = r.duration @playing = r.playing @song = r.song - @t = r.t + + @remoteT = r.t + @remoteAsOfMs = now + + + + diff -r 3843f6bd0460 -r 2d77dc9436c3 light9/web/light9-music.html --- a/light9/web/light9-music.html Sat Jun 04 20:43:31 2016 +0000 +++ b/light9/web/light9-music.html Sat Jun 04 21:23:58 2016 +0000 @@ -4,8 +4,18 @@ diff -r 3843f6bd0460 -r 2d77dc9436c3 light9/web/timeline-elements.html --- a/light9/web/timeline-elements.html Sat Jun 04 20:43:31 2016 +0000 +++ b/light9/web/timeline-elements.html Sat Jun 04 21:23:58 2016 +0000 @@ -30,18 +30,14 @@ position: absolute; left: 0; top: 0; right: 0; bottom: 0; } - #debug { - position: fixed; - right: 0; - bottom: 0; - }
- - timeline editor: song [uri] + + timeline editor: song [{{song}}]
+
[[debug]]