Changeset - b64a4db527e2
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 6 years ago 2019-06-10 23:50:04
drewp@bigasterisk.com
whitespace
Ignore-this: 82ab84810df09d549904116da2c3e4b8
1 file changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light9/web/light9-vidref-replay.js
Show inline comments
 
@@ -16,20 +16,22 @@ class Light9VidrefReplay extends LitElem
 
            outVideoCurrentTime: { type: Number },
 
            timeErr: { type: Number },
 
            playRate: { type: Number },
 
            size: { type: String, attribute: true }
 
        };
 
    }
 

	
 
    estimateRate() {
 
        const n = this.songToVideo.length;
 
        const x0 = Math.round(n * .3);
 
        const x1 = Math.round(n * .6);
 
        const pt0 = this.songToVideo[x0];
 
        const pt1 = this.songToVideo[x1];
 
        return (pt1[1] - pt0[1]) / (pt1[0] - pt0[0]);
 
    }
 

	
 
    setVideoTimeFromSongTime(songTime, isPlaying) {
 
        if (!this.songToVideo || !this.outVideo || this.outVideo.readyState < 1) {
 
            return;
 
        }
 
        const i = _.sortedIndex(this.songToVideo, [songTime],
 
                                (row) => { return row[0]; });
 
@@ -61,12 +63,13 @@ class Light9VidrefReplay extends LitElem
 
        } else {
 
            this.outVideo.pause();
 
            this.outVideoCurrentTime = this.outVideo.currentTime = this.videoTime;
 
            this.timeErr = 0;
 
        }
 
    }
 

	
 
    setRate(r) {
 
        this.playRate = Math.max(.1, Math.min(4, r));
 
        this.outVideo.playbackRate = this.playRate;
 
    }
 

	
 
    firstUpdated() {
 
@@ -100,39 +103,40 @@ class Light9VidrefReplay extends LitElem
 
            color: #29ffa0;
 
        }
 
        a {
 
            color: rgb(97, 97, 255);
 
        }
 
        video {
 
          width: 100%;
 
            width: 100%;
 
        }
 
        `;
 
    }
 
    
 
    render() {
 
        let details = '';
 
        if (this.size != 'small') {
 
            details = html`  <div>
 
            details = html`
 
  <div>
 
    take is <a href="${this.uri}">${this.uri}</a> 
 
    (${Object.keys(this.songToVideo).length} frames)
 
    <button @click="${this.onDelete}">Delete</button>
 
  </div>
 
  <!-- here, put a little canvas showing what coverage we have with the 
 
       actual/goal time cursors -->
 
  <div>
 
    video time should be <span class="num">${this.videoTime} </span>
 
    actual = <span class="num">${rounding(this.outVideoCurrentTime, 3, 3, true)}</span>, 
 
    err = <span class="num">${rounding(this.timeErr, 3, 4, true)}</span>
 
    rate = <span class="num">${rounding(this.playRate, 3, 3, true)}</span>
 
  </div>
 
`;
 
            `;
 
        }
 
        return html`
 
  <video id="replay" class="size-${this.size}" src="${this.videoUrl}"></video>
 
${details}
 
  `;
 
          <video id="replay" class="size-${this.size}" src="${this.videoUrl}"></video>
 
          ${details}
 
        `;
 

	
 
    }
 
}
 
customElements.define('light9-vidref-replay', Light9VidrefReplay);
 
window.thresh=.3
 
window.p=.3
0 comments (0 inline, 0 general)