问题描述
我正在使用reactjs和以下代码打开视频。在旧的浏览器(webos 2.0浏览器)中会发生此问题。我正在尝试为Lg Webos开发一个项目。
const videoRef = useRef(null);
useEffect(() => {
const options = {
html5: {
vhs: {
overrideNative: true,},nativeAudioTracks: false,nativeVideoTracks: false,fill: true,fluid: true,controls: true,preload: "none",};
const nodeVideo = videoRef.current;
try {
const vjsPlayer = videojs(//It gives the error here
nodeVideo,{
...options,() => {
if (vjsPlayer) {
vjsPlayer.load();
setPlayer(vjsPlayer);
}
}
);
return () => {
if (vjsPlayer) {
vjsPlayer.dispose();
console.log("player disposed!!!");
}
};
} catch (error) {
console.log("error: ",error);
}
},[]);
//........
//...........
return(
<div>
<div data-vjs-player>
<video ref={videoRef} className="video-js vjs-16-9" />
</div>
</div>
)
videojs有时会在代码中指定的部分失败。 Videojs不初始化。有时尝试5次,有时尝试30次。因此尚不清楚何时会失败。
给出错误后,它仍然会创建一个如下所示的dom。实际上似乎是不完全的初始化
<div>
<div data-vjs-player="true">
<video class="video-js vjs-16-9"></video>
</div>
</div>
当我尝试再次打开相同或不同的视频时,该视频在大约1分钟后无法打开。我认为videojs仍在后台运行并等待结束。
如何终止完全运行的Videojs?没有处理问题,因此可以在错误发生前的尝试中正确处理。
我找不到任何解决方案..
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)