有没有在React-Native-Web中播放视频的解决方案
React-Native-Web:https://github.com/necolas/react-native-web https://github.com/necolas/react-native-web
反应本机视频:https://github.com/react-native-community/react-native-video https://github.com/react-native-community/react-native-video
我不知道这个解决方案有多可行,但由于您的目标是网络,您可以使用和滥用createElement
from react-native-web
创建视频元素。
例如,您可以创建一个像这样的无状态组件:
import { createElement } from "react-native-web";
const Video = (props) => {
const attrs = {
src: props.source,
poster: props.poster,
controls: "controls"
}
return createElement("video", attrs)
}
export default Video
然后在您的应用程序中使用它,如下所示:
<Video
source={require("./stock_video.mp4")}
poster={'https://www.fillmurray.com/480/300'}
/>
这里有一点demo https://codesandbox.io/s/cold-butterfly-qpbvh它将如何运作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)