简体   繁体   English

react-hls-player 流媒体视频

[英]react-hls-player streaming video

I am using react-hls-player in my project.我在我的项目中使用 react-hls-player。 this is my sample code这是我的示例代码

 const playerRef = useRef();
    return (
      <ReactHlsPlayer
          playerRef={playerRef}
          src="http://sample.vodobox.com/planete_interdite/planete_interdite_alternate.m3u8"
          autoPlay={false}
          controls={true}
          width="100%"
          height="auto"
         
      />
  );

i want to know is there any way to change hls video quality?我想知道有什么方法可以改变 hls 视频质量吗?

you can use this package , it supports a callback for the HLS Player object as soon as it becomes available in the component.你可以使用这个package ,它支持 HLS Player object 的回调,只要它在组件中可用。 You can then use this HLS object to change the video quality by setting the currentLevel the documentation is available here然后,您可以使用此 HLS object 通过设置currentLevel来更改视频质量,文档可在此处获得

react-hls-player uses hls.js under the hood. react-hls-player在后台使用hls.js You can get the HLS player instance by using ref .您可以使用ref获取 HLS 播放器实例。

You can change the level(video quality) by setting currentLevel in hls.js您可以通过在hls.js中设置currentLevel来更改级别(视频质量)

See the documentation for more information.有关更多信息,请参阅文档

Update:更新:

It seems like react-hls-player does not expose hls instance.似乎react-hls-player没有公开hls实例。 You can see from source code that playerRef is a reference to video tag.源码中可以看出playerRef是对video标签的引用。 So you cannot access hls API.所以你无法访问hls API。

You can do two things:你可以做两件事:

  1. Patch the package and expose hls instance.修补 package 并公开hls实例。
  2. Write your own React component.编写你自己的 React 组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM