2019-01-25, 08:37 AM
The following will allow your users to embed HLS stream videos in their posts.
Regular Expression (regex site):
Replacement:
Test Value:
To allow users to set auto play and mute options you will need to adapt the code.
Regular Expression (regex site):
\[m3u8\](?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))\[/m3u8\]
Replacement:
<video id="video" width="800" height="600" controls autoplay
class="videoCentered"></video>
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.js"></script>
<script>
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls({ autoStartLoad:false });
hls.loadSource('$1');
hls.attachMedia(video);
hls.startLoad(1);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
hls.startLoad(20);
video.play();
});
}
</script>
Test Value:
[m3u8]https://nn.geo.joj.sk/live/hls/jojplus-360.m3u8[/m3u8]
To allow users to set auto play and mute options you will need to adapt the code.