视频播放器仓库

App.js 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React, { Component } from 'react';
  2. // import { DefaultPlayer as Video } from 'react-html5video';
  3. import { DefaultPlayer as Video } from '../../../dist/index.js';
  4. import 'react-html5video/dist/styles.css';
  5. import styles from './App.css';
  6. import 'reset-css/reset.css';
  7. import vttEn from './../../assets/sintel-en.vtt';
  8. import vttEs from './../../assets/sintel-es.vtt';
  9. import bigBuckBunnyPoster from './../../assets/poster-big-buck-bunny.png';
  10. import sintelTrailerPoster from './../../assets/poster-sintel-trailer.png';
  11. const sintelTrailer = 'https://download.blender.org/durian/trailer/sintel_trailer-720p.mp4';
  12. const bigBuckBunny = 'http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov';
  13. class App extends Component {
  14. render () {
  15. return (
  16. <div className={styles.component}>
  17. <header className={styles.header}>
  18. <h1 className={styles.title}>React HTML5 Video</h1>
  19. <a className={styles.link}
  20. href="https://github.com/mderrick/react-html5video">
  21. View on GitHub &raquo;
  22. </a>
  23. </header>
  24. <ul className={styles.videoList}>
  25. <li className={styles.videoListItem}>
  26. <Video
  27. autoPlay
  28. ref="video1"
  29. onPlay={() => {
  30. this.refs.video2.videoEl.pause();
  31. }}
  32. onScreenClickCallback={()=>{
  33. debugger;
  34. }}
  35. data-playbackrates={JSON.stringify([{
  36. id: 0.5, name: '0.5x', mode: 'disabled'
  37. },{
  38. id: 0.75, name: '0.75x', mode: 'disabled'
  39. },{
  40. id: 1, name: 'Normal', mode: 'showing'
  41. },{
  42. id: 1.25, name: '1.25x', mode: 'disabled'
  43. },{
  44. id: 1.5, name: '1.5x', mode: 'disabled'
  45. },{
  46. id: 2, name: '2x', mode: 'disabled'
  47. }])}
  48. poster={sintelTrailerPoster}>
  49. <source src={sintelTrailer} type="video/mp4" />
  50. <track
  51. label="English"
  52. kind="subtitles"
  53. srcLang="en"
  54. src={vttEn}
  55. default />
  56. <track
  57. label="Español"
  58. kind="subtitles"
  59. srcLang="es"
  60. src={vttEs} />
  61. </Video>
  62. </li>
  63. <li className={styles.videoListItem}>
  64. <Video
  65. ref="video2"
  66. onPlay={() => {
  67. this.refs.video1.videoEl.pause();
  68. }}
  69. src={bigBuckBunny}
  70. poster={bigBuckBunnyPoster}>
  71. </Video>
  72. </li>
  73. </ul>
  74. </div>
  75. );
  76. }
  77. }
  78. export default App;