aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-05-11 05:35:56 +0300
committerRblSb <msrblsb@gmail.com>2020-05-11 05:35:56 +0300
commit13660e01338b392b777db31817f7db1728c54140 (patch)
treebf01798ec7c996bfc84f364519c42c1ceb702571
parentcd98a6fa51c8e18c13c62603d67a0880c53e729a (diff)
Fix playback rate on setTime
-rw-r--r--build/server.js1
-rw-r--r--src/server/VideoTimer.hx1
-rw-r--r--test/tests/TestTimer.hx23
3 files changed, 18 insertions, 7 deletions
diff --git a/build/server.js b/build/server.js
index 3be172e..6635826 100644
--- a/build/server.js
+++ b/build/server.js
@@ -3843,6 +3843,7 @@ server_VideoTimer.prototype = {
}
,setTime: function(secs) {
this.startTime = Date.now() / 1000 - secs;
+ this.rateStartTime = Date.now() / 1000;
if(this.isPaused()) {
this.pause();
}
diff --git a/src/server/VideoTimer.hx b/src/server/VideoTimer.hx
index 508b97b..53d4e28 100644
--- a/src/server/VideoTimer.hx
+++ b/src/server/VideoTimer.hx
@@ -46,6 +46,7 @@ class VideoTimer {
public function setTime(secs:Float):Void {
startTime = stamp() - secs;
+ rateStartTime = stamp();
if (isPaused()) pause();
}
diff --git a/test/tests/TestTimer.hx b/test/tests/TestTimer.hx
index 9403b75..cbc71d2 100644
--- a/test/tests/TestTimer.hx
+++ b/test/tests/TestTimer.hx
@@ -2,13 +2,15 @@ package test.tests;
import haxe.PosInfos;
import utest.Assert;
+import utest.Test;
+import utest.Async;
import haxe.Timer;
import server.VideoTimer;
-class TestTimer extends utest.Test {
+class TestTimer extends Test {
@:timeout(500)
- function testMain(async:utest.Async) {
+ function testMain(async:Async) {
final timer = new VideoTimer();
timer.start();
Timer.delay(() -> {
@@ -29,12 +31,19 @@ class TestTimer extends utest.Test {
Assert.equals(0, timer.getTime());
Assert.equals(true, timer.isPaused());
Assert.equals(false, timer.isStarted);
- async.done();
+ timer.start();
+ timer.setRate(3);
}, 300);
+ Timer.delay(() -> {
+ almostEq(0.3, timer.getTime());
+ timer.setTime(0.1);
+ almostEq(0.1, timer.getTime());
+ async.done();
+ }, 400);
}
@:timeout(500)
- function testRate(async:utest.Async) {
+ function testRate(async:Async) {
final timer = new VideoTimer();
timer.start();
timer.setRate(2);
@@ -65,7 +74,7 @@ class TestTimer extends utest.Test {
}
@:timeout(500)
- function testRatePause(async:utest.Async) {
+ function testRatePause(async:Async) {
final timer = new VideoTimer();
timer.start();
timer.setRate(2);
@@ -98,7 +107,7 @@ class TestTimer extends utest.Test {
}
@:timeout(500)
- function testPauseRate(async:utest.Async) {
+ function testPauseRate(async:Async) {
final timer = new VideoTimer();
timer.start();
timer.setTime(100);
@@ -129,7 +138,7 @@ class TestTimer extends utest.Test {
}
@:timeout(500)
- function testBigRate(async:utest.Async) {
+ function testBigRate(async:Async) {
final timer = new VideoTimer();
timer.start();
timer.setRate(3);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage