HTML5视频下拉质量hls.js

发布于 2025-01-24 15:20:43 字数 931 浏览 2 评论 0 原文

我使用标签html5视频 + hls.js进行视频流。M3U8HOE

<div class="container-video"> 
            <video id="video" 
                width="700" 
                height="400"
                preload="auto" 
                controls>
                <source [src]="videoLink" type="application/x-mpegURL">
            </video>
        </div>

  playVideoLive(videoLink) {
      const video = document.getElementsByTagName('video')[0];
      if (Hls.isSupported()) {
        var hls = new Hls();
        hls.loadSource(videoLink);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED, function () {
          video.play();
        });
      }
      else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = videoLink;
        video.addEventListener('canplay', function () {
          video.play();
        });
    }
  }

我可以显示质量视频列表的下拉列表吗?

I'm use a tag html5 video + hls.js for video streaming .m3u8

<div class="container-video"> 
            <video id="video" 
                width="700" 
                height="400"
                preload="auto" 
                controls>
                <source [src]="videoLink" type="application/x-mpegURL">
            </video>
        </div>

  playVideoLive(videoLink) {
      const video = document.getElementsByTagName('video')[0];
      if (Hls.isSupported()) {
        var hls = new Hls();
        hls.loadSource(videoLink);
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED, function () {
          video.play();
        });
      }
      else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = videoLink;
        video.addEventListener('canplay', function () {
          video.play();
        });
    }
  }

Hoe i can show the dropdown with the list of quality video?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞慾 2025-01-31 15:20:43

您可以使用额外的软件包添加A轨道选择器 - 可能还有其他包装,但这似乎很受欢迎: https://www.npmjs.com/package/videojs-hls-quality-selector

您也可以添加自己的控件,并通过API使用:

有一个演示在此处使用API​​(在写作时) - 转到演示页面的底部以查看级别,您可以单击它们在那里:

You can use an extra package to add the a track selector - there may be others but this one seems quite popular: https://www.npmjs.com/package/videojs-hls-quality-selector

You can also add your own controls and do it via the API using: https://github.com/video-dev/hls.js/blob/master/docs/API.md#hlscurrentlevel

There is a demo which uses the API here (at the time of writing) - go to the bottom of the demo page to see the levels and you can click on them there: https://hls-js-dev.netlify.app/demo/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文