my eye

Use callbacks for script injection

Committed c9a305

--- a/webint_live/templates/stream.html
+++ b/webint_live/templates/stream.html

       const streams = data.getElementsByTagName('stream')
       if (streams.length) {
         window.injectStylesheet('/assets/video.js-5.8.8.css')
-        window.injectScript('/assets/video.js-5.8.8.js')
-        window.injectScript('/assets/video.js-contrib-hls-3.6.12.js')
+        window.injectScript('/assets/video.js-5.8.8.js', () => {
+          window.injectScript('/assets/video.js-contrib-hls-3.6.12.js', () => {
+            document.querySelector('#stream').innerHTML = `
+              <video id=livestream class="video-js vjs-default-skin" controls>
+                <source src=$tx.origin/hls/foo.m3u8 type=application/x-mpegURL>
+              </video>
+              <div style=font-size:.75em>started <span id=streamduration></span>
+              minutes ago</div>
+            `
+            player = videojs('livestream', {fluid: true})
+            player.play()
 
-        document.querySelector('#stream').innerHTML = `
-          <video id=livestream class="video-js vjs-default-skin" controls>
-            <source src=$tx.origin/hls/foo.m3u8 type=application/x-mpegURL>
-          </video>
-          <div style=font-size:.75em>started <span id=streamduration></span>
-          minutes ago</div>
-        `
-        player = videojs('livestream', {fluid: true})
-        player.play()
-
-        const ms = parseInt(streams[0].getElementsByTagName('time')[0].textContent)
-        document.querySelector('#streamduration').innerHTML = Math.round(ms / 1000 / 60)
+            const ms = parseInt(streams[0].getElementsByTagName('time')[0].textContent)
+            document.querySelector('#streamduration').innerHTML = Math.round(ms / 1000 / 60)
+          })
+        })
       }
     })
     .catch(error => {