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
This commit is contained in:
Matt Mascarenhas 2018-05-15 20:45:03 +01:00
parent 845a824d62
commit 426cbfccba
2 changed files with 3 additions and 6 deletions

View File

@ -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])

View File

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