config.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. const langs = [
  2. { title: 'English', path: '/home', matchPath: /^\/(home|ecosystem)/ },
  3. { title: '简体中文', path: '/zh-Hans/', matchPath: /^\/zh-Hans/ },
  4. ];
  5. docute.init({
  6. landing: 'landing.html',
  7. title: 'DPlayer',
  8. repo: 'DIYgod/DPlayer',
  9. twitter: 'DIYgod',
  10. 'edit-link': 'https://github.com/MoePlayer/DPlayer/tree/master/docs',
  11. nav: {
  12. default: [
  13. {
  14. title: 'Home', path: '/home'
  15. },
  16. {
  17. title: 'Ecosystem', path: '/ecosystem'
  18. },
  19. {
  20. title: 'Languages', type: 'dropdown', items: langs
  21. }
  22. ],
  23. 'zh-Hans': [
  24. {
  25. title: '首页', path: '/zh-Hans/'
  26. },
  27. {
  28. title: '生态', path: '/zh-Hans/ecosystem'
  29. },
  30. {
  31. title: '选择语言', type: 'dropdown', items: langs
  32. }
  33. ],
  34. },
  35. plugins: [
  36. docsearch({
  37. apiKey: '46a8ba306e368972c1d75feb581fb430',
  38. indexName: 'dplayer',
  39. tags: ['english', 'zh-Hans'],
  40. url: 'http://dplayer.js.org'
  41. }),
  42. evanyou(),
  43. player()
  44. ]
  45. });
  46. function player () {
  47. return function (context) {
  48. context.event.on('landing:updated', function () {
  49. console.log('landing:updated');
  50. clearPlayer();
  51. dplayer1();
  52. });
  53. context.event.on('content:updated', function () {
  54. console.log('content:updated');
  55. clearPlayer();
  56. for (let i = 0; i < document.querySelectorAll('.load').length; i++) {
  57. document.querySelectorAll('.load')[i].addEventListener('click', function () {
  58. window[this.parentElement.id] && window[this.parentElement.id]();
  59. });
  60. }
  61. });
  62. };
  63. }
  64. function clearPlayer () {
  65. for (let i = 1; i < 10; i++) {
  66. if (window['dp' + (i + 1)]) {
  67. window['dp' + (i + 1)].destroy();
  68. }
  69. }
  70. }
  71. function dplayer1 () {
  72. window.dp1 = new DPlayer({
  73. container: document.getElementById('dplayer1'),
  74. screenshot: true,
  75. video: {
  76. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
  77. pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
  78. thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg'
  79. },
  80. subtitle: {
  81. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.vtt'
  82. },
  83. danmaku: {
  84. id: '9E2E3368B56CDBB4',
  85. api: 'https://api.prprpr.me/dplayer/'
  86. }
  87. });
  88. }
  89. function dplayer2 () {
  90. window.dp2 = new DPlayer({
  91. container: document.getElementById('dplayer2'),
  92. screenshot: true,
  93. video: {
  94. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
  95. pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
  96. thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg'
  97. },
  98. subtitle: {
  99. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.vtt'
  100. },
  101. danmaku: {
  102. id: '9E2E3368B56CDBB4',
  103. api: 'https://api.prprpr.me/dplayer/'
  104. }
  105. });
  106. }
  107. function dplayer3 () {
  108. window.dp3 = new DPlayer({
  109. container: document.getElementById('dplayer3'),
  110. autoplay: false,
  111. theme: '#FADFA3',
  112. loop: true,
  113. lang: 'zh-cn',
  114. screenshot: true,
  115. hotkey: true,
  116. preload: 'auto',
  117. logo: 'https://moeplayer.b0.upaiyun.com/dplayer/DPlayer.png',
  118. volume: 0.7,
  119. mutex: true,
  120. video: {
  121. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
  122. pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
  123. thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg',
  124. type: 'auto'
  125. },
  126. subtitle: {
  127. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.vtt',
  128. type: 'webvtt',
  129. fontSize: '25px',
  130. bottom: '10%',
  131. color: '#b7daff'
  132. },
  133. danmaku: {
  134. id: '9E2E3368B56CDBB4',
  135. api: 'https://api.prprpr.me/dplayer/',
  136. token: 'tokendemo',
  137. maximum: 1000,
  138. addition: ['https://api.prprpr.me/dplayer/bilibili?aid=4157142'],
  139. user: 'DIYgod',
  140. bottom: '15%',
  141. unlimited: true
  142. },
  143. contextmenu: [
  144. {
  145. text: 'custom1',
  146. link: 'https://github.com/DIYgod/DPlayer'
  147. },
  148. {
  149. text: 'custom2',
  150. click: (player) => {
  151. console.log(player);
  152. }
  153. }
  154. ]
  155. });
  156. }
  157. function dplayer4 () {
  158. window.dp4 = new DPlayer({
  159. container: document.getElementById('dplayer4'),
  160. video: {
  161. quality: [{
  162. name: 'HD',
  163. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
  164. type: 'hls'
  165. }, {
  166. name: 'SD',
  167. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4',
  168. type: 'normal'
  169. }],
  170. defaultQuality: 0,
  171. pic: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.png',
  172. thumbnails: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara_thumbnails.jpg'
  173. }
  174. });
  175. }
  176. function dplayer5 () {
  177. window.dp5 = new DPlayer({
  178. container: document.getElementById('dplayer5'),
  179. video: {
  180. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
  181. type: 'hls'
  182. }
  183. });
  184. }
  185. function dplayer6 () {
  186. window.dp6 = new DPlayer({
  187. container: document.getElementById('dplayer6'),
  188. video: {
  189. url: 'https://moeplayer.b0.upaiyun.com/dplayer/dash/hikarunara.mpd',
  190. type: 'dash'
  191. }
  192. });
  193. }
  194. function dplayer7 () {
  195. window.dp7 = new DPlayer({
  196. container: document.getElementById('dplayer7'),
  197. video: {
  198. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.flv',
  199. type: 'flv'
  200. }
  201. });
  202. }
  203. function dplayer8 () {
  204. window.dp8 = new DPlayer({
  205. container: document.getElementById('dplayer8'),
  206. video: {
  207. url: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
  208. type: 'webtorrent'
  209. }
  210. });
  211. }
  212. function dplayer9 () {
  213. window.dp9 = new DPlayer({
  214. container: document.getElementById('dplayer9'),
  215. live: true,
  216. danmaku: true,
  217. apiBackend: {
  218. read: function (endpoint, callback) {
  219. console.log('Pretend to connect WebSocket');
  220. callback();
  221. },
  222. send: function (endpoint, danmakuData, callback) {
  223. console.log('Pretend to send danamku via WebSocket', danmakuData);
  224. callback();
  225. }
  226. },
  227. video: {
  228. url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
  229. type: 'hls'
  230. }
  231. });
  232. }