summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-20 19:26:26 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-20 19:26:26 +0200
commit5f2a721426c5e55e755c65b946910ba752acf327 (patch)
treed8639225cd1ee85297bf038f30a968b220f4f932
parentd6e7b1e32b9395ae8699461ba7c58059e5712d49 (diff)
rudimentary pausejabber
-rw-r--r--public/assets/js/app.js10
-rw-r--r--public/index.html2
-rw-r--r--rpc/rpc.py11
3 files changed, 11 insertions, 12 deletions
diff --git a/public/assets/js/app.js b/public/assets/js/app.js
index af37bc4..83cbefe 100644
--- a/public/assets/js/app.js
+++ b/public/assets/js/app.js
@@ -1,4 +1,4 @@
-const container = document.querySelector('#container')
+const player = document.querySelector('#player')
let socket = io.connect('/client')
let got_frame = false
@@ -21,17 +21,13 @@ socket.on('res', (data) => {
socket.on('frame', (data) => {
got_frame = true
- // console.log('frame', data.fn)
- // console.log(data.frame)
- // return
const blob = new Blob([data.frame], { type: 'image/jpg' })
const url = URL.createObjectURL(blob)
-
const img = new Image ()
img.onload = function() {
URL.revokeObjectURL(url)
- container.innerHTML = ''
- container.appendChild(img)
+ player.innerHTML = ''
+ player.appendChild(img)
}
img.src = url
})
diff --git a/public/index.html b/public/index.html
index 04817a1..fef1a7f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -10,7 +10,7 @@
<link rel="stylesheet" href="/assets/css/css.css">
</head>
<body>
- <div id="container"></div>
+ <div id="player"></div>
</body>
<script src="/socket.io/socket.io.js"></script>
<script>
diff --git a/rpc/rpc.py b/rpc/rpc.py
index 957a049..3239c44 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -13,7 +13,7 @@ class CortexRPC(object):
def __init__(self, fn):
super().__init__()
self._listener = fn
- self.fetching = False
+ self.working = False
self.connect()
def connect(self):
@@ -40,14 +40,17 @@ class CortexRPC(object):
# return self.get_last_frame()
def get_last_frame(self):
- if self.fetching:
+ if self.working:
+ self.working = False
return "working"
path = os.getenv('TEST_FRAMES_PATH')
onlyfiles = sorted([f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))])
- self.fetching = True
+ self.working = True
for f in onlyfiles:
gevent.sleep(1/10)
+ if not self.working:
+ return
output = BytesIO()
im = Image.open(os.path.join(path, f))
# im = im.convert('RGB')
@@ -56,7 +59,7 @@ class CortexRPC(object):
output.close()
self.send_frame(f.replace('png', 'jpg'), frame)
- self.fetching = False
+ self.working = False
return "ok"
def send_param(self, key, value):