【发布时间】:2018-12-07 04:12:05
【问题描述】:
我正在尝试使用 react-html5video 以及在服务器端渲染中实现示例视频播放器组件。为此我使用了next.js。
- 首先,我在 ./pages/playerPage.js 下创建了一个名为 playerPage 的文件
- 然后我在 ./components/player.js 下创建了播放器组件
- 然后关注https://github.com/mderrick/react-html5video/blob/1.4.0/README.md#advanced-usage
- 这是我的播放器组件的外观。
import React from ‘react’;
import { default as Video, Controls, Play, Mute, Seek, Fullscreen, Time, Overlay } from ‘react-html5video’;
class Player extends React.Component {
render() {
return (
<div>
<Video controls autoPlay loop muted poster=“http://sourceposter.jpg“>
<source src=“http://sourcefile.mp4” type=“video/mp4" />
<source src=“http://sourcefile.webm” type=“video/webm” />
<h1>Optional HTML and components can be added also</h1>
<Overlay />
<Controls>
<Play />
<Seek />
<Time />
<Mute />
<Fullscreen />
</Controls>
</Video>
</div>
);
}
}
export default Player;
- 现在在 playerpage.js 中导入 player.js 组件。
import Player from '../components/player'
export default () => (
<Player />
)
我已经在ZEIT community 中提到了我的问题,其中一位说:
听起来 react-html5video 和服务器端渲染什么的不兼容。
现在我很困惑:有没有兼容 react 和服务器端渲染的视频播放器??
我们将不胜感激。
【问题讨论】:
标签: javascript html reactjs html5-video next.js