summaryrefslogtreecommitdiff
path: root/app/client/live/player.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-29 18:51:27 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-29 18:51:27 +0200
commitfe8cef1b709f09f508f17d0d6d06f204dd44a8bb (patch)
tree75c03c0734106dda0a4e5b407778b58ec758d029 /app/client/live/player.js
parent7d71a0248a8746088142bb51ce4248c76f274f30 (diff)
pushing files to s3.. filelist color
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