如何解决如何在网站上渲染Firebase Storage视频?
从其他SO答案(例如Firebase Storage: Play back of a video url directly?)中,我了解到Firebase不支持视频流,因此我不能仅在URL中提供<video>
元素并希望它播放资源。这样,我该如何在网站上显示存储在Firebase Storage中的视频?
解决方法
Firebase存储仅支持文件下载。因此您需要使用getDownloadUrl here:
这就是我在React中的操作方式:
import React,{ useEffect,useState } from "react";
import ReactPlayer from 'react-player/lazy';
import { storage } from "../../firebase/fbConfig"
const VideoView = (props) => {
const [vedio,loadVedio] = useState("");
const vedioLoader = info => {
storage.ref().child(VIDEO_REF).getDownloadURL().then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function (event) {
var blob = xhr.response;
};
xhr.open('GET',url);
xhr.send();
loadVedio(url)
console.log(url)
}).catch((error) => {
console.log(error)
})
}
return (
<ReactPlayer id="myVedio"
url={vedio}
width='100%'
height='100%'
playing={true}
controls={true}
volume={1}
progressInterval={5000}
pip={true}
/>
)
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。