From 426cbfccba65f469987a68e1ff5c9b2caff26482 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Tue, 15 May 2018 20:45:03 +0100 Subject: [PATCH] cinera_player_pre.js: Use YouTube API's timer This lets users of Firefox 59+ get sub-millisecond accurate performance: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now --- cinera/cinera.c | 3 ++- cinera/cinera_player_pre.js | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cinera/cinera.c b/cinera/cinera.c index c61c878..7672db7 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -16,7 +16,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 50 + .Patch = 51 }; // TODO(matt): Copy in the DB 3 stuff from cinera_working.c @@ -787,6 +787,7 @@ StringsDifferT(char *A, // NOTE(matt): Null-terminated string char Terminator // NOTE(matt): Caller definable terminator. Pass 0 to only match on the extent of A ) { + // TODO(matt): Make sure this can't crash upon reaching the end of B's buffer int ALength = StringLength(A); int i = 0; while(i < ALength && A[i] && A[i] == B[i]) diff --git a/cinera/cinera_player_pre.js b/cinera/cinera_player_pre.js index 035340f..2a7ee7c 100644 --- a/cinera/cinera_player_pre.js +++ b/cinera/cinera_player_pre.js @@ -43,7 +43,6 @@ function Player(htmlContainer, refsCallback) { this.pauseAfterBuffer = false; this.speed = 1; this.currentTime = -1; - this.lastFrameTime = 0; this.scrollTo = -1; this.scrollPosition = 0; this.nextFrame = null; @@ -250,11 +249,8 @@ Player.prototype.updateProgress = function() { }; Player.prototype.doFrame = function() { - var now = performance.now(); - var delta = (now - this.lastFrameTime) / 1000.0; - this.lastFrameTime = now; if (this.playing) { - this.currentTime += delta * this.speed; + this.currentTime = this.youtubePlayer.getCurrentTime(); } this.updateProgress();