~hristoast/hristoast

253477a10cdd860abe392b06413cc0696405aff8 — Hristos N. Triantafillou 2 years ago cc79fd0
Update the stream to use HLS instead of dash

This should have better compatibility with iThings.
3 files changed, 53 insertions(+), 3 deletions(-)

A site/js/stream.js
M site/video/stream.html
M soupault.conf
A site/js/stream.js => site/js/stream.js +38 -0
@@ 0,0 1,38 @@
/*
  hristoast - stream.js
  Copyright (C) 2019  Hristos N. Triantafillou

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

var video = document.getElementsByTagName("video")[0];
var vidsrc = "https://vs.bhgdo.com/vs/dagoth-ur.m3u8";

function loadHLS() {
    if(Hls.isSupported()) {
        var hls = new Hls();
        hls.loadSource(vidsrc);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED, function() {
            video.play();
        });
    }
    else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = vidsrc;
        video.addEventListener('loadedmetadata', function() {
            video.play();
        });
    }
}
window.onload = loadHLS();

M site/video/stream.html => site/video/stream.html +2 -2
@@ 1,4 1,4 @@
<h3>Live Video Stream</h3>
<p>Sometimes I do things and stream video of it.</p>
<video data-dashjs-player autoplay src="/dash/live.mpd" controls></video>
<script src='/dash/dash.all.min.js' type='text/javascript'></script>

<video id="stream" controls></video>

M soupault.conf => soupault.conf +13 -1
@@ 69,11 69,23 @@
  link_text = "Source link for this page"
  repo_base = "https://git.sr.ht/~hristoast/hristoast/tree/master/"

[widgets.hls-js]
  widget = "insert-if"
  html = "<script src='https://vs.bhgdo.com/vs/hls.js' type='text/javascript'></script>"
  selector = "body"
  check_selector = "video#stream"

[widgets.stream-js]
  widget = "insert-if"
  html = "<script src='/js/stream.js' type='text/javascript'></script>"
  selector = "body"
  check_selector = "video#stream"

[widgets.vidpos-js]
  widget = "insert-if"
  html = "<script src='/js/vidpos.js' type='text/javascript'></script>"
  selector = "body"
  check_selector = "video"
  check_selector = "video#video"

[widgets.footnotes]
  widget = "footnotes"