安装:

  1. npm install --save video-react
  2. 或者
  3. yarn add video-react

使用示例:

  1. import React, { Component, Fragment } from 'react';
  2. import path from './guide.mp4'
  3. import {
  4. Player,
  5. ControlBar,
  6. PlayToggle, // PlayToggle 播放/暂停按钮 若需禁止加 disabled
  7. ReplayControl, // 后退按钮
  8. ForwardControl, // 前进按钮
  9. CurrentTimeDisplay,
  10. TimeDivider,
  11. PlaybackRateMenuButton, // 倍速播放选项
  12. VolumeMenuButton
  13. } from 'video-react';
  14. import "../node_modules/video-react/dist/video-react.css"; // import css
  15. class AAA extends Component {
  16. componentDidMount() {
  17. console.log(this.player)
  18. this.player.subscribeToStateChange(this.handleStateChange.bind(this));
  19. }
  20. handleStateChange(state, prevState) {
  21. console.log(state)
  22. }
  23. render() {
  24. return (
  25. <Fragment>
  26. <div style={{ width: 500, height: 300, margin: 50 }}>
  27. <Player
  28. ref={c => {
  29. this.player = c;
  30. }}
  31. poster="https://video-react.js.org/assets/poster.png"
  32. >
  33. <source
  34. src={path}
  35. type="video/mp4"
  36. />
  37. <ControlBar autoHide={false} disableDefaultControls={false}>
  38. <ReplayControl seconds={10} order={1.1} />
  39. <ForwardControl seconds={30} order={1.2} />
  40. <PlayToggle />
  41. <CurrentTimeDisplay order={4.1} />
  42. <TimeDivider order={4.2} />
  43. <PlaybackRateMenuButton rates={[5, 2, 1.5, 1, 0.5]} order={7.1} />
  44. <VolumeMenuButton />
  45. </ControlBar>
  46. </Player>
  47. </div>
  48. </Fragment>
  49. )
  50. }
  51. }
  52. export default AAA;

——————————————————————————————————————————————
https://video-react.js.org/
MongoDB
Python/Django
Webpack
MySQL
R