如何从Firebase存储中加载视频并将其作为React组件返回?

发布于 2025-01-28 17:01:30 字数 348 浏览 5 评论 0原文

我在Firebase存储中存储了一个视频,并且可以从Firebase访问它的下载URL并尝试这样做:

const App = () => {
  var videoRef = storage.ref('myVideo.mp4')
  return (
    <video width="750" height="500" controls>
      <source src={videoRef.getDownloadURL()} />
    </video>
  )
}

控制台中没有任何错误,但没有加载视频。

有办法这样做吗?

提前致谢!

I have a video stored in my firebase storage and and I'm able to access it's download URL from firebase and trying to do this:

const App = () => {
  var videoRef = storage.ref('myVideo.mp4')
  return (
    <video width="750" height="500" controls>
      <source src={videoRef.getDownloadURL()} />
    </video>
  )
}

There aren't any errors coming up in the console but it doesn't load the video.

Is there a way to do this?

Thank's in advance!

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

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

发布评论

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

评论(1

小情绪 2025-02-04 17:01:30

如果您只想播放一个视频,则可以转到保存该视频的Firebase存储空间。单击它,在您的右边,您将看到名称属性。右键单击下面的链接,然后复制链接地址。
然后,您可以这样做:

<source src="put the link here" />

if it is only one video you want to play, you can go to your firebase storage where you saved that video. Click on it, to your right you will see Name property. Right click on link below and copy link address.
You can then do this:

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