Reputation: 63
From other SO answers (e.g Firebase Storage: Play back of a video url directly?), I understand that Firebase does not support video streaming so I can't just provide a <video>
element my URL and expect it to playback the resource. As such, how would I go about displaying videos which are stored in Firebase Storage on my website?
Upvotes: 0
Views: 1572
Reputation: 2477
Firebase storage support only files download. so you need to use getDownloadUrl here:
This is how I do it in 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}
/>
)
}
Upvotes: 1