在React-Native-Web中播放视频有什么解决方案吗
React-Native-网站:https://github.com/necolas/react-native-web
React-原生视频:https://github.com/react-native-community/react-native-video
发布于 2019-12-14 17:33:29
我不知道这个解决方案有多可行,但既然你的目标是web,你可以使用和滥用react-native-web的createElement来创建视频元素。
例如,您可以像这样创建一个无状态组件:
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://stackoverflow.com/questions/59318412
复制相似问题