Changeset - c8f0d1b9a171
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 6 years ago 2019-06-09 04:45:24
drewp@bigasterisk.com
timeline scrubbing shows up on vidref (again)
Ignore-this: 62d3c7ffc411949e211c6e286f551b55
3 files changed with 31 insertions and 5 deletions:
0 comments (0 inline, 0 general)
bin/vidref
Show inline comments
 
@@ -97,22 +97,35 @@ class Live(cyclone.websocket.WebSocketHa
 

	
 

	
 
class SnapshotPic(cyclone.web.StaticFileHandler):
 
    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):
 
        clip = URIRef(self.get_argument('uri'))
 
        videorecorder.deleteClip(clip)
 

	
 
@@ -171,12 +184,13 @@ reactor.listenTCP(
 
            (r'/replayMap', ReplayMap),
 
            (r'/snapshot', Snapshot),
 
            (r'/snapshot/(.*)', SnapshotPic, {
 
                "path": 'todo',
 
            }),
 
            (r'/time', Time),
 
            (r'/time/stream', TimeStream),
 
            (r'/stats/(.*)', StatsHandler, {
 
                'serverName': 'vidref'
 
            }),
 
        ],
 
        debug=True,
 
    ))
light9/web/light9-vidref-replay-stack.js
Show inline comments
 
@@ -32,13 +32,13 @@ class Light9VidrefReplayStack extends Li
 
    }
 
    fineTime() {       
 
        if (this.musicState.playing) {
 
            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));
 
    }
 

	
 
    updated(changedProperties) {
 
        if (changedProperties.has('songTime')) {
 
@@ -48,12 +48,13 @@ class Light9VidrefReplayStack extends Li
 

	
 
    firstUpdated() {
 
        this.songTimeRangeInput = this.shadowRoot.querySelector('#songTime');
 

	
 
        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();
 
    }
 

	
 
    receivedSongAndTime(msg) {
 
        this.musicState = msg;
 
@@ -64,12 +65,23 @@ class Light9VidrefReplayStack extends Li
 

	
 
        if (this.musicState.song != this.song) {
 
            this.song = this.musicState.song;
 
            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);
 
        u.pathname = '/vidref/replayMap'
 
        u.searchParams.set('song', song);
 
        fetch(u.toString()).then((resp) => {
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -212,13 +212,13 @@ coffeeElementSetup(class TimelineEditor 
 
        # should be controlled by a checkbox next to follow-player-song-choice
 
        @sendMouseToVidref() unless window.location.hash.match(/novidref/)
 

	
 
  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
 

	
 
  bindWheelZoom: (elem) ->
 
    elem.addEventListener 'mousewheel', (ev) =>
 
      @viewState.onMouseWheel(ev.deltaY)
0 comments (0 inline, 0 general)