aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/VideoTimer.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-13 16:28:18 +0300
committerRblSb <msrblsb@gmail.com>2020-02-15 19:45:40 +0300
commit07d1955cefc093ffb12002902ed45e963030746e (patch)
tree8833eca2dc2ef07891aa8eb66daf7ad90f2ab0ce /src/server/VideoTimer.hx
Initial commit
Diffstat (limited to 'src/server/VideoTimer.hx')
-rw-r--r--src/server/VideoTimer.hx54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/server/VideoTimer.hx b/src/server/VideoTimer.hx
new file mode 100644
index 0000000..695ea5d
--- /dev/null
+++ b/src/server/VideoTimer.hx
@@ -0,0 +1,54 @@
+package server;
+
+import haxe.Timer;
+
+class VideoTimer {
+
+ public var isStarted(default, null) = false;
+ var startTime = 0.0;
+ var pauseStartTime = 0.0;
+
+ public function new() {}
+
+ public function start():Void {
+ isStarted = true;
+ startTime = Timer.stamp();
+ pauseStartTime = 0;
+ }
+
+ public function stop():Void {
+ isStarted = false;
+ startTime = 0.0;
+ pauseStartTime = 0.0;
+ }
+
+ public function pause():Void {
+ pauseStartTime = Timer.stamp();
+ }
+
+ public function play():Void {
+ if (!isStarted) start();
+ startTime += pauseTime();
+ pauseStartTime = 0;
+ }
+
+ public function getTime():Float {
+ if (startTime == 0) return 0;
+ return Timer.stamp() - startTime - pauseTime();
+ }
+
+ public function setTime(secs:Float):Void {
+ startTime = Timer.stamp() - secs;
+ if (isPaused()) pause();
+ }
+
+ public function isPaused():Bool {
+ return pauseStartTime != 0;
+ }
+
+ function pauseTime():Float {
+ if (!isPaused()) return 0;
+ return Timer.stamp() - pauseStartTime;
+ }
+
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage