Mercurial > code > home > repos > light9
changeset 1986:c8f0d1b9a171
timeline scrubbing shows up on vidref (again)
Ignore-this: 62d3c7ffc411949e211c6e286f551b55
author | drewp@bigasterisk.com |
---|---|
date | Sun, 09 Jun 2019 04:45:24 +0000 |
parents | 47ef9c9efe38 |
children | 522d7bf9b5b2 |
files | bin/vidref light9/web/light9-vidref-replay-stack.js light9/web/timeline/timeline.coffee |
diffstat | 3 files changed, 31 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/vidref Sun Jun 09 02:04:56 2019 +0000 +++ b/bin/vidref Sun Jun 09 04:45:24 2019 +0000 @@ -100,16 +100,29 @@ pass -class Time(cyclone.web.RequestHandler): +class Time(PrettyErrorHandler, cyclone.web.RequestHandler): def put(self): body = json.loads(self.request.body) t = body['t'] - source = body['source'] - self.settings.gui.incomingTime(t, source) + for listener in TimeStream.time_stream_listeners: + listener.sendMessage(json.dumps({ + 'st': t, + 'song': body['song'], + })) self.set_status(202) +class TimeStream(cyclone.websocket.WebSocketHandler): + time_stream_listeners = [] + + def connectionMade(self, *args, **kwargs): + TimeStream.time_stream_listeners.append(self) + + def connectionLost(self, reason): + TimeStream.time_stream_listeners.remove(self) + + class Clips(PrettyErrorHandler, cyclone.web.RequestHandler): def delete(self): @@ -174,6 +187,7 @@ "path": 'todo', }), (r'/time', Time), + (r'/time/stream', TimeStream), (r'/stats/(.*)', StatsHandler, { 'serverName': 'vidref' }),
--- a/light9/web/light9-vidref-replay-stack.js Sun Jun 09 02:04:56 2019 +0000 +++ b/light9/web/light9-vidref-replay-stack.js Sun Jun 09 04:45:24 2019 +0000 @@ -35,7 +35,7 @@ const sinceLastUpdate = (Date.now() - this.musicState.reportTime) / 1000; this.songTime = sinceLastUpdate + this.musicState.tStart; } else { - this.songTime = this.musicState.t; + // this.songTime = this.musicState.t; } requestAnimationFrame(this.fineTime.bind(this)); } @@ -51,6 +51,7 @@ const ws = reconnectingWebSocket('../ascoltami/time/stream', this.receivedSongAndTime.bind(this)); + reconnectingWebSocket('time/stream', this.receivedRemoteScrubbedTime.bind(this)); // bug: upon connecting, clear this.song this.fineTime(); } @@ -67,6 +68,17 @@ this.getReplayMapForSong(this.song); } } + + receivedRemoteScrubbedTime(msg) { + this.songTime = msg.st; + + // This doesn't work completely since it will keep getting + // updates from ascoltami slow updates. + if (msg.song != this.song) { + this.song = msg.song; + this.getReplayMapForSong(this.song); + } + } getReplayMapForSong(song) { const u = new URL(window.location.href);
--- a/light9/web/timeline/timeline.coffee Sun Jun 09 02:04:56 2019 +0000 +++ b/light9/web/timeline/timeline.coffee Sun Jun 09 04:45:24 2019 +0000 @@ -215,7 +215,7 @@ sendMouseToVidref: -> now = Date.now() if (!@$.vidrefLastSent? || @$.vidrefLastSent < now - 200) && !@songPlaying - @$.vidrefTime.body = {t: @viewState.latestMouseTime(), source: 'timeline'} + @$.vidrefTime.body = {t: @viewState.latestMouseTime(), source: 'timeline', song: @song} @$.vidrefTime.generateRequest() @$.vidrefLastSent = now