有没有在 React-Native-Web 中播放视频的解决方案
React-Native-Web:https://github.com/necolas/react-native-web
react 原生视频:https://github.com/react-native-community/react-native-video
最佳答案
我不知道这个解决方案有多可行,但由于你的目标是网络,你可以使用和滥用 createElement
来自 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它是如何工作的。
关于javascript - React-Native-Web 的视频支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59318412/