# HG changeset patch # User drewp@bigasterisk.com # Date 2019-06-09 04:45:24 # Node ID c8f0d1b9a171b2e7ab2abb90fc8b793ee346ccee # Parent 47ef9c9efe3865f6612c86d0c8d48fe4024866bc timeline scrubbing shows up on vidref (again) Ignore-this: 62d3c7ffc411949e211c6e286f551b55 diff --git a/bin/vidref b/bin/vidref --- a/bin/vidref +++ b/bin/vidref @@ -100,16 +100,29 @@ class SnapshotPic(cyclone.web.StaticFile 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 @@ reactor.listenTCP( "path": 'todo', }), (r'/time', Time), + (r'/time/stream', TimeStream), (r'/stats/(.*)', StatsHandler, { 'serverName': 'vidref' }), diff --git a/light9/web/light9-vidref-replay-stack.js b/light9/web/light9-vidref-replay-stack.js --- a/light9/web/light9-vidref-replay-stack.js +++ b/light9/web/light9-vidref-replay-stack.js @@ -35,7 +35,7 @@ class Light9VidrefReplayStack extends Li 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 @@ class Light9VidrefReplayStack extends Li 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 @@ class Light9VidrefReplayStack extends Li 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); diff --git a/light9/web/timeline/timeline.coffee b/light9/web/timeline/timeline.coffee --- a/light9/web/timeline/timeline.coffee +++ b/light9/web/timeline/timeline.coffee @@ -215,7 +215,7 @@ coffeeElementSetup(class TimelineEditor 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