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
 
@@ -91,34 +91,47 @@ class Live(cyclone.websocket.WebSocketHa
 

	
 
        self.sendMessage(
 
            json.dumps({
 
                'jpeg': base64.b64encode(cf.asJpeg()).decode('ascii'),
 
                'description': f't={cf.t}',
 
            }))
 

	
 

	
 
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)
 

	
 

	
 
class ReplayMap(PrettyErrorHandler, cyclone.web.RequestHandler):
 

	
 
    def get(self):
 
        song = Song(self.get_argument('song'))
 
        clips = []
 
@@ -165,21 +178,22 @@ reactor.listenTCP(
 
            (r'/setup/()', cyclone.web.StaticFileHandler, {
 
                'path': 'light9/vidref',
 
                'default_filename': 'setup.html'
 
            }),
 
            (r'/live', Live),
 
            (r'/clips', Clips),
 
            (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,
 
    ))
 
log.info("serving on %s" % port)
 

	
 
reactor.run()
light9/web/light9-vidref-replay-stack.js
Show inline comments
 
@@ -26,57 +26,69 @@ class Light9VidrefReplayStack extends Li
 
                r.setVideoTimeFromSongTime(this.songTime, this.musicState.playing);
 
            });
 
    }
 
    nudgeTime(dt) {
 
        this.songTime += dt;
 
        log('song now', this.songTime);
 
    }
 
    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')) {
 
            this.setVideoTimesFromSongTime();
 
        }
 
    }
 

	
 
    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;
 
        this.musicState.reportTime = Date.now();
 
        this.musicState.tStart = this.musicState.t;            
 

	
 
        this.songTimeRangeInput.max = this.musicState.duration;
 

	
 
        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) => {
 
            if (resp.ok) {
 
                resp.json().then((msg) => {
 
                    this.players = msg.map(this.makeClipRow.bind(this));
 
                    this.updateComplete.then(this.setupClipRows.bind(this, msg));
 
                });
 
            }
 
        });          
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -206,25 +206,25 @@ coffeeElementSetup(class TimelineEditor 
 
        if ev.touches?.length
 
          ev = ev.touches[0]
 

	
 
        root = @$.cursorCanvas.getBoundingClientRect()
 
        @viewState.mouse.pos($V([ev.pageX - root.left, ev.pageY - root.top]))
 

	
 
        # 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)
 

	
 
  bindKeys: ->
 
    shortcut.add "Ctrl+P", (ev) =>
 
      @$.music.seekPlayOrPause(@viewState.latestMouseTime())
 
    shortcut.add "Ctrl+Escape", => @viewState.frameAll()
 
    shortcut.add "Shift+Escape", => @viewState.frameToEnd()
0 comments (0 inline, 0 general)