index.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>DPlayer Demo</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  7. <style>
  8. body {
  9. font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  10. }
  11. .container {
  12. max-width: 40rem;
  13. margin-left: auto;
  14. margin-right: auto;
  15. margin-bottom: 50px;
  16. }
  17. h1 {
  18. font-size: 54px;
  19. color: #333;
  20. margin: 30px 0 10px;
  21. }
  22. h2 {
  23. font-size: 22px;
  24. color: #555;
  25. }
  26. h3 {
  27. font-size: 24px;
  28. color: #555;
  29. }
  30. hr {
  31. display: block;
  32. width: 7rem;
  33. height: 1px;
  34. margin: 2.5rem 0;
  35. background-color: #eee;
  36. border: 0;
  37. }
  38. a {
  39. color: #08c;
  40. text-decoration: none;
  41. }
  42. p {
  43. font-size: 18px;
  44. }
  45. </style>
  46. <link rel="stylesheet" href="../dist/DPlayer.min.css">
  47. </head>
  48. <body>
  49. <div class="container">
  50. <h1>DPlayer</h1>
  51. <h2>Wow, such a lovely HTML5 danmaku video player</h2>
  52. <p>Made by <a href="https://www.anotherhome.net/" target="_blank">DIYgod</a>. Available on <a href="https://github.com/DIYgod/DPlayer" target="_blank">GitHub</a>. Licensed SATA.</p>
  53. <hr>
  54. <h3>Normal</h3>
  55. <div id="dplayer1"></div>
  56. <button onclick="switchDPlayer()">Switch Video</button>
  57. <button onclick="dp1.notice('Notice演示')">Notice</button>
  58. <h3>Quality switching</h3>
  59. <div id="dplayer6"></div>
  60. <button onclick="dp6.switchQuality(1)">Switch quality</button>
  61. <h3>Live Video (HTTP Live Streaming, M3U8 format) support</h3>
  62. <div id="dplayer3"></div>
  63. <h3>FLV format support</h3>
  64. <div id="dplayer4"></div>
  65. <h3>Bilibili video and danmaku support</h3>
  66. <div id="dplayer2"></div>
  67. <!--<h3>Segmented videos</h3>
  68. <div id="dplayer5"></div>-->
  69. </div>
  70. <script src="https://rawgit.com/mrdoob/stats.js/master/build/stats.min.js"></script>
  71. <script src="../plugin/flv.min.js"></script>
  72. <script src="../plugin/hls.min.js"></script>
  73. <script src="../dist/DPlayer.min.js"></script>
  74. <script>
  75. // Normal
  76. var dp1 = new DPlayer({
  77. element: document.getElementById('dplayer1'),
  78. autoplay: false,
  79. theme: '#FADFA3',
  80. loop: true,
  81. screenshot: true,
  82. hotkey: true,
  83. logo: 'http://devtest.qiniudn.com/DPlayer.png',
  84. video: {
  85. url: 'http://devtest.qiniudn.com/若能绽放光芒.mp4',
  86. pic: 'http://devtest.qiniudn.com/若能绽放光芒.png',
  87. type: 'auto',
  88. },
  89. danmaku: {
  90. id: '9E2E3368B56CDBB4',
  91. api: 'https://api.prprpr.me/dplayer/',
  92. token: 'tokendemo',
  93. maximum: 3000,
  94. user: 'DIYgod的女粉'
  95. },
  96. contextmenu: [
  97. {
  98. text: '关于作者',
  99. link: 'http://diygod.me'
  100. },
  101. {
  102. text: '播放器意见反馈',
  103. link: 'https://github.com/DIYgod/DPlayer/issues'
  104. },
  105. {
  106. text: '关于 DPlayer 播放器',
  107. link: 'https://github.com/DIYgod/DPlayer'
  108. },
  109. {
  110. text: '自定义右键菜单demo',
  111. link: 'https://github.com/DIYgod/DPlayer'
  112. },
  113. ]
  114. });
  115. function switchDPlayer() {
  116. if (dp1.option.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
  117. dp1.switchVideo({
  118. url: 'http://devtest.qiniudn.com/微小微-江南皮革厂倒闭了.mp4',
  119. pic: 'http://devtest.qiniudn.com/微小微-江南皮革厂倒闭了.jpg',
  120. type: 'auto',
  121. },
  122. {
  123. id: '5rGf5Y2X55qu6Z2p',
  124. api: 'https://api.prprpr.me/dplayer/',
  125. token: 'tokendemo',
  126. maximum: 3000
  127. });
  128. }
  129. else {
  130. dp1.switchVideo({
  131. url: 'http://devtest.qiniudn.com/若能绽放光芒.mp4',
  132. pic: 'http://devtest.qiniudn.com/若能绽放光芒.png',
  133. type: 'auto',
  134. },
  135. {
  136. id: '9E2E3368B56CDBB4',
  137. api: 'https://api.prprpr.me/dplayer/',
  138. token: 'tokendemo',
  139. maximum: 3000
  140. });
  141. }
  142. }
  143. // Bilibili video and danmaku support
  144. var dp2 = new DPlayer({
  145. element: document.getElementById('dplayer2'),
  146. autoplay: false,
  147. theme: '#FADFA3',
  148. loop: true,
  149. screenshot: false,
  150. logo: 'http://devtest.qiniudn.com/DPlayer.png',
  151. video: {
  152. url: 'https://api.prprpr.me/dplayer/video/bilibili?aid=4045652',
  153. pic: 'http://devtest.qiniudn.com/微小微-江南皮革厂倒闭了.jpg',
  154. type: 'auto',
  155. },
  156. danmaku: {
  157. id: '5rGf5Y2X55qu6Z2p',
  158. api: 'https://api.prprpr.me/dplayer/',
  159. token: 'tokendemo',
  160. maximum: 3000,
  161. addition: ['https://api.prprpr.me/dplayer/bilibili?aid=4045652']
  162. }
  163. });
  164. // Live Video (HTTP Live Streaming, M3U8 format) support
  165. var dp3 = new DPlayer({
  166. element: document.getElementById('dplayer3'),
  167. autoplay: false,
  168. theme: '#FADFA3',
  169. loop: true,
  170. screenshot: true,
  171. hotkey: true,
  172. logo: 'http://devtest.qiniudn.com/DPlayer.png',
  173. video: {
  174. url: 'http://devtest.qiniudn.com/若能绽放光芒5.m3u8',
  175. pic: 'http://devtest.qiniudn.com/若能绽放光芒.png',
  176. type: 'hls',
  177. },
  178. danmaku: {
  179. id: '9E2E3368B56CDBB42',
  180. api: 'https://api.prprpr.me/dplayer/',
  181. token: 'tokendemo',
  182. maximum: 3000
  183. }
  184. });
  185. // FLV format support
  186. var dp4 = new DPlayer({
  187. element: document.getElementById('dplayer4'),
  188. autoplay: false,
  189. theme: '#FADFA3',
  190. loop: true,
  191. screenshot: true,
  192. hotkey: true,
  193. logo: 'http://devtest.qiniudn.com/DPlayer.png',
  194. video: {
  195. url: 'http://devtest.qiniudn.com/【微小微】玖月奇迹-踩踩踩.flv',
  196. pic: 'http://devtest.qiniudn.com/【微小微】玖月奇迹-踩踩踩.jpg',
  197. type: 'flv',
  198. },
  199. danmaku: {
  200. id: '9E2E3368B56CDBB43',
  201. api: 'https://api.prprpr.me/dplayer/',
  202. token: 'tokendemo',
  203. maximum: 3000
  204. }
  205. });
  206. // Segmented videos
  207. // var dp5 = new DPlayer({
  208. // element: document.getElementById('dplayer5'),
  209. // autoplay: false,
  210. // theme: '#FADFA3',
  211. // loop: true,
  212. // screenshot: true,
  213. // hotkey: true,
  214. // preload: 'metadata',
  215. // video: {
  216. // url: ['http://devtest.qiniudn.com/若能绽放光芒0.mp4', 'http://devtest.qiniudn.com/若能绽放光芒1.mp4', 'http://devtest.qiniudn.com/若能绽放光芒2.mp4', 'http://devtest.qiniudn.com/若能绽放光芒3.mp4', 'http://devtest.qiniudn.com/若能绽放光芒4.mp4', 'http://devtest.qiniudn.com/若能绽放光芒5.mp4', 'http://devtest.qiniudn.com/若能绽放光芒6.mp4', 'http://devtest.qiniudn.com/若能绽放光芒7.mp4', 'http://devtest.qiniudn.com/若能绽放光芒8.mp4'],
  217. // pic: 'http://devtest.qiniudn.com/若能绽放光芒.png',
  218. // type: 'normal',
  219. // },
  220. // danmaku: {
  221. // id: '9E2E3368B56CDBB40',
  222. // api: 'https://api.prprpr.me/dplayer/',
  223. // token: 'tokendemo',
  224. // maximum: 3000
  225. // }
  226. // });
  227. // Quality switching
  228. var dp6 = new DPlayer({
  229. element: document.getElementById('dplayer6'),
  230. autoplay: false,
  231. theme: '#FADFA3',
  232. loop: true,
  233. screenshot: true,
  234. hotkey: true,
  235. logo: 'http://devtest.qiniudn.com/DPlayer.png',
  236. video: {
  237. quality: [{
  238. name: '高清',
  239. url: 'http://devtest.qiniudn.com/若能绽放光芒.mp4?1'
  240. }, {
  241. name: '超清',
  242. url: 'http://devtest.qiniudn.com/若能绽放光芒.mp4?2'
  243. }],
  244. defaultQuality: 0,
  245. pic: 'http://devtest.qiniudn.com/若能绽放光芒.png',
  246. type: 'auto',
  247. },
  248. danmaku: {
  249. id: '9E2E3368B56CDBB4',
  250. api: 'https://api.prprpr.me/dplayer/',
  251. token: 'tokendemo',
  252. maximum: 3000,
  253. user: 'DIYgod的女粉'
  254. }
  255. });
  256. // stats.js: JavaScript Performance Monitor
  257. var stats = new Stats();
  258. stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
  259. document.body.appendChild(stats.dom);
  260. function animate() {
  261. stats.begin();
  262. // monitored code goes here
  263. stats.end();
  264. requestAnimationFrame(animate);
  265. }
  266. requestAnimationFrame(animate);
  267. </script>
  268. <a href="https://github.com/DIYgod/DPlayer" target="_blank" class="github-corner"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
  269. </body>
  270. </html>