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:
parent
845a824d62
commit
426cbfccba
|
@ -16,7 +16,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 5,
|
.Minor = 5,
|
||||||
.Patch = 50
|
.Patch = 51
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
|
// 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
|
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 ALength = StringLength(A);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i < ALength && A[i] && A[i] == B[i])
|
while(i < ALength && A[i] && A[i] == B[i])
|
||||||
|
|
|
@ -43,7 +43,6 @@ function Player(htmlContainer, refsCallback) {
|
||||||
this.pauseAfterBuffer = false;
|
this.pauseAfterBuffer = false;
|
||||||
this.speed = 1;
|
this.speed = 1;
|
||||||
this.currentTime = -1;
|
this.currentTime = -1;
|
||||||
this.lastFrameTime = 0;
|
|
||||||
this.scrollTo = -1;
|
this.scrollTo = -1;
|
||||||
this.scrollPosition = 0;
|
this.scrollPosition = 0;
|
||||||
this.nextFrame = null;
|
this.nextFrame = null;
|
||||||
|
@ -250,11 +249,8 @@ Player.prototype.updateProgress = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.doFrame = function() {
|
Player.prototype.doFrame = function() {
|
||||||
var now = performance.now();
|
|
||||||
var delta = (now - this.lastFrameTime) / 1000.0;
|
|
||||||
this.lastFrameTime = now;
|
|
||||||
if (this.playing) {
|
if (this.playing) {
|
||||||
this.currentTime += delta * this.speed;
|
this.currentTime = this.youtubePlayer.getCurrentTime();
|
||||||
}
|
}
|
||||||
this.updateProgress();
|
this.updateProgress();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue