React Material UI CardMedia视频组件无法播放 [英] React Material UI CardMedia video component not playing

查看:69
本文介绍了React Material UI CardMedia视频组件无法播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到缩略图,但是无法开始或停止视频,也可以自动播放并重复播放吗?

I see a thumbnail but no way to start or stop the video, also is there any way to have it autoplay and repeat?

https://material-ui.com/api/card-media/

<CardMedia
component="video"
image='/video.mp4'
title='title'
/>                       

推荐答案

要显示控件,您需要添加控件属性以在渲染时显示控件(这没有记录,但是 html5 中的视频控件我们需要设置 controls属性进行显示).

To show controls you need to add controls attribute to show contols on render (This is not documented, but video control in html5 we need to set controls attribute to show it).

也不要忘记添加mui文档指定的特定高度的样式. https://material-ui.com/api/card-media/#cardmedia-api

Also don't forget to add style with some specific height as specified by mui documentation. https://material-ui.com/api/card-media/#cardmedia-api

<CardMedia
component="video"
image='/video.mp4'
title='title'
controls
/>  

这篇关于React Material UI CardMedia视频组件无法播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆