summaryrefslogtreecommitdiff
path: root/app/client/live/player.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/live/player.js')
-rw-r--r--app/client/live/player.js43
1 files changed, 32 insertions, 11 deletions
diff --git a/app/client/live/player.js b/app/client/live/player.js
index 808e79e..37f7cab 100644
--- a/app/client/live/player.js
+++ b/app/client/live/player.js
@@ -66,15 +66,36 @@ export function onFrame (data) {
img.src = url
}
-setInterval(() => {
- store.dispatch({
- type: types.player.set_fps,
- fps: fps,
- })
- store.dispatch({
- type: types.player.current_frame,
- meta: last_frame,
- })
- fps = 0
-}, 1000)
+let previousValue, currentValue
+function handleChange() {
+ let previousValue = currentValue
+ currentValue = store.getState().live.playing
+
+ if (previousValue !== currentValue) {
+ if (currentValue) {
+ startWatchingFPS()
+ } else {
+ stopWatchingFPS()
+ }
+ }
+}
+
+let fpsInterval;
+function startWatchingFPS(){
+ clearInterval(fpsInterval)
+ fpsInterval = setInterval(() => {
+ store.dispatch({
+ type: types.player.set_fps,
+ fps: fps,
+ })
+ store.dispatch({
+ type: types.player.current_frame,
+ meta: last_frame,
+ })
+ fps = 0
+ }, 1000)
+}
+function stopWatchingFPS(){
+ clearInterval(fpsInterval)
+} \ No newline at end of file