方法一:直接使用插件hexo-tag-video-js
直接使用这个插件hexo-tag-video-js即可
插入代码:
1
| {% videojs "source=m3u8视频链接" %}
|
效果如下:
方法二:使用jsdelivr做hls解析
代码模板:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <div style="position: relative; width: 100%; height: 0; padding-bottom: 75%;"> <video id="video" controls loop="false" style="position: absolute; width: 100%; height: 100%; Left: 0; top: 0;"></video> </div> <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> <script> var video = document.getElementById('video'); if(Hls.isSupported()) { var hls = new Hls(); hls.loadSource('m3u8视频链接'); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED,function() { }); } else if (video.canPlayType('application/vnd.apple.mpegurl')) { video.src = 'm3u8视频链接'; video.addEventListener('loadedmetadata',function() { }); } </script>
|
效果展示: