xgplayer 2.32.5 → 2.32.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/browser/controls/airplay.js +1 -1
  2. package/browser/controls/cssFullscreen.js +1 -1
  3. package/browser/controls/danmu.js +3 -1
  4. package/browser/controls/definition.js +1 -1
  5. package/browser/controls/download.js +1 -1
  6. package/browser/controls/enter.js +1 -1
  7. package/browser/controls/error.js +1 -1
  8. package/browser/controls/errorRetry.js +1 -1
  9. package/browser/controls/flex.js +1 -1
  10. package/browser/controls/fullscreen.js +1 -1
  11. package/browser/controls/loading.js +1 -1
  12. package/browser/controls/memoryPlay.js +1 -1
  13. package/browser/controls/miniplayer.js +9 -7
  14. package/browser/controls/mobile.js +1 -1
  15. package/browser/controls/nativeTextTrack.js +1 -1
  16. package/browser/controls/pc.js +1 -1
  17. package/browser/controls/pip.js +1 -1
  18. package/browser/controls/play.js +1 -1
  19. package/browser/controls/playNext.js +1 -1
  20. package/browser/controls/playbackRate.js +1 -1
  21. package/browser/controls/poster.js +1 -1
  22. package/browser/controls/progress.js +1 -1
  23. package/browser/controls/reload.js +1 -1
  24. package/browser/controls/replay.js +1 -1
  25. package/browser/controls/rotate.js +1 -1
  26. package/browser/controls/screenShot.js +1 -1
  27. package/browser/controls/start.js +1 -1
  28. package/browser/controls/textTrack.js +1 -1
  29. package/browser/controls/time.js +1 -1
  30. package/browser/controls/volume.js +1 -1
  31. package/browser/core_player.js +1 -1
  32. package/browser/core_player.js.map +1 -1
  33. package/browser/index.js +11 -7
  34. package/browser/index.js.map +1 -1
  35. package/browser/simple_player.js +1 -1
  36. package/browser/simple_player.js.map +1 -1
  37. package/dist/controls/airplay.js +1 -1
  38. package/dist/controls/cssFullscreen.js +1 -1
  39. package/dist/controls/danmu.js +3 -1
  40. package/dist/controls/definition.js +1 -1
  41. package/dist/controls/download.js +1 -1
  42. package/dist/controls/enter.js +1 -1
  43. package/dist/controls/error.js +1 -1
  44. package/dist/controls/errorRetry.js +1 -1
  45. package/dist/controls/flex.js +1 -1
  46. package/dist/controls/fullscreen.js +1 -1
  47. package/dist/controls/loading.js +1 -1
  48. package/dist/controls/memoryPlay.js +1 -1
  49. package/dist/controls/miniplayer.js +9 -7
  50. package/dist/controls/mobile.js +1 -1
  51. package/dist/controls/nativeTextTrack.js +1 -1
  52. package/dist/controls/pc.js +1 -1
  53. package/dist/controls/pip.js +1 -1
  54. package/dist/controls/play.js +1 -1
  55. package/dist/controls/playNext.js +1 -1
  56. package/dist/controls/playbackRate.js +1 -1
  57. package/dist/controls/poster.js +1 -1
  58. package/dist/controls/progress.js +1 -1
  59. package/dist/controls/reload.js +1 -1
  60. package/dist/controls/replay.js +1 -1
  61. package/dist/controls/rotate.js +1 -1
  62. package/dist/controls/screenShot.js +1 -1
  63. package/dist/controls/start.js +1 -1
  64. package/dist/controls/textTrack.js +1 -1
  65. package/dist/controls/time.js +1 -1
  66. package/dist/controls/volume.js +1 -1
  67. package/dist/core_player.js +2960 -2889
  68. package/dist/core_player.js.map +1 -1
  69. package/dist/index.js +1938 -3321
  70. package/dist/index.js.map +1 -1
  71. package/dist/index.min.css +1 -0
  72. package/dist/index.min.js +2 -0
  73. package/dist/index.min.js.map +1 -0
  74. package/dist/simple_player.js +274 -281
  75. package/dist/simple_player.js.map +1 -1
  76. package/es/_virtual/_rollupPluginBabelHelpers.js +216 -0
  77. package/es/constant.d.ts +4 -0
  78. package/es/constant.js +5 -0
  79. package/es/controls/airplay.js +1 -1
  80. package/es/controls/cssFullscreen.js +1 -1
  81. package/es/controls/danmu.js +3 -1
  82. package/es/controls/definition.js +1 -1
  83. package/es/controls/download.js +1 -1
  84. package/es/controls/enter.js +1 -1
  85. package/es/controls/error.js +1 -1
  86. package/es/controls/errorRetry.js +1 -1
  87. package/es/controls/flex.js +1 -1
  88. package/es/controls/fullscreen.js +1 -1
  89. package/es/controls/i18n.js +1 -1
  90. package/es/controls/keyboard.js +1 -1
  91. package/es/controls/loading.js +1 -1
  92. package/es/controls/localPreview.js +1 -1
  93. package/es/controls/memoryPlay.js +1 -1
  94. package/es/controls/miniplayer.js +9 -7
  95. package/es/controls/mobile.js +1 -1
  96. package/es/controls/nativeTextTrack.js +1 -1
  97. package/es/controls/pc.js +1 -1
  98. package/es/controls/pip.js +1 -1
  99. package/es/controls/play.js +1 -1
  100. package/es/controls/playNext.js +1 -1
  101. package/es/controls/playbackRate.js +1 -1
  102. package/es/controls/poster.js +1 -1
  103. package/es/controls/progress.js +1 -1
  104. package/es/controls/reload.js +1 -1
  105. package/es/controls/replay.js +1 -1
  106. package/es/controls/rotate.js +1 -1
  107. package/es/controls/screenShot.js +1 -1
  108. package/es/controls/start.js +1 -1
  109. package/es/controls/textTrack.js +1 -1
  110. package/es/controls/time.js +1 -1
  111. package/es/controls/volume.js +1 -1
  112. package/es/core_player.js +1 -1
  113. package/es/core_player.js.map +1 -1
  114. package/es/defaultConfig.d.ts +243 -0
  115. package/es/defaultConfig.js +85 -0
  116. package/es/error.d.ts +114 -0
  117. package/es/error.js +75 -0
  118. package/es/events.d.ts +61 -0
  119. package/es/events.js +62 -0
  120. package/es/icons.d.ts +2 -0
  121. package/es/index.css +499 -0
  122. package/es/index.d.ts +25 -0
  123. package/es/index.js +11 -7
  124. package/es/index.js.map +1 -1
  125. package/es/index.scss +29 -0
  126. package/es/index.umd.d.ts +60 -0
  127. package/es/index.umd.js +30 -0
  128. package/es/lang/en.d.ts +91 -0
  129. package/es/lang/en.js +77 -0
  130. package/es/lang/i18n.d.ts +36 -0
  131. package/es/lang/i18n.js +122 -0
  132. package/es/lang/index.d.ts +2 -0
  133. package/es/lang/jp.d.ts +91 -0
  134. package/es/lang/jp.js +77 -0
  135. package/es/lang/zh-cn.d.ts +91 -0
  136. package/es/lang/zh-cn.js +77 -0
  137. package/es/lang/zh-hk.d.ts +91 -0
  138. package/es/lang/zh-hk.js +77 -0
  139. package/es/mediaProxy.d.ts +334 -0
  140. package/es/mediaProxy.js +623 -0
  141. package/es/player.d.ts +825 -0
  142. package/es/player.js +1945 -0
  143. package/es/plugin/basePlugin.d.ts +180 -0
  144. package/es/plugin/basePlugin.js +259 -0
  145. package/es/plugin/hooksDescriptor.d.ts +60 -0
  146. package/es/plugin/hooksDescriptor.js +149 -0
  147. package/es/plugin/index.d.ts +13 -0
  148. package/es/plugin/plugin.d.ts +207 -0
  149. package/es/plugin/plugin.js +542 -0
  150. package/es/plugin/pluginsManager.d.ts +162 -0
  151. package/es/plugin/pluginsManager.js +362 -0
  152. package/es/plugin/preset.d.ts +1 -0
  153. package/es/plugin/preset.js +28 -0
  154. package/es/plugin/resizeObserver.d.ts +3 -0
  155. package/es/plugin/resizeObserver.js +108 -0
  156. package/es/plugins/assets/back.js +4 -0
  157. package/es/plugins/assets/download.js +4 -0
  158. package/es/plugins/assets/exitCssFull.js +4 -0
  159. package/es/plugins/assets/exitFull.js +4 -0
  160. package/es/plugins/assets/loading.js +4 -0
  161. package/es/plugins/assets/panel.js +4 -0
  162. package/es/plugins/assets/pause.js +4 -0
  163. package/es/plugins/assets/pipIcon.js +4 -0
  164. package/es/plugins/assets/pipIconExit.js +4 -0
  165. package/es/plugins/assets/play.js +4 -0
  166. package/es/plugins/assets/playNext.js +4 -0
  167. package/es/plugins/assets/replay.js +4 -0
  168. package/es/plugins/assets/requestCssFull.js +7 -0
  169. package/es/plugins/assets/requestFull.js +4 -0
  170. package/es/plugins/assets/rotate.js +4 -0
  171. package/es/plugins/assets/seekicon.js +4 -0
  172. package/es/plugins/assets/volumeLarge.js +4 -0
  173. package/es/plugins/assets/volumeMuted.js +4 -0
  174. package/es/plugins/assets/volumeSmall.js +4 -0
  175. package/es/plugins/common/iconPlugin.d.ts +5 -0
  176. package/es/plugins/common/iconPlugin.js +42 -0
  177. package/es/plugins/common/iconTools.d.ts +1 -0
  178. package/es/plugins/common/iconTools.js +8 -0
  179. package/es/plugins/common/index.scss +2 -0
  180. package/es/plugins/common/optionList.d.ts +15 -0
  181. package/es/plugins/common/optionList.js +120 -0
  182. package/es/plugins/common/optionsIcon.d.ts +40 -0
  183. package/es/plugins/common/optionsIcon.js +304 -0
  184. package/es/plugins/common/optionsIcon.scss +154 -0
  185. package/es/plugins/common/thumbnail.d.ts +62 -0
  186. package/es/plugins/common/thumbnail.js +191 -0
  187. package/es/plugins/common/thumbnail.scss +27 -0
  188. package/es/plugins/controls/index.css +132 -0
  189. package/es/plugins/controls/index.d.ts +73 -0
  190. package/es/plugins/controls/index.js +189 -0
  191. package/es/plugins/controls/index.scss +204 -0
  192. package/es/plugins/cssFullScreen/index.css +12 -0
  193. package/es/plugins/cssFullScreen/index.d.ts +40 -0
  194. package/es/plugins/cssFullScreen/index.js +136 -0
  195. package/es/plugins/cssFullScreen/index.scss +19 -0
  196. package/es/plugins/danmu/danmuIcon.d.ts +24 -0
  197. package/es/plugins/danmu/danmuIcon.js +98 -0
  198. package/es/plugins/danmu/danmuPanel.d.ts +39 -0
  199. package/es/plugins/danmu/danmuPanel.js +81 -0
  200. package/es/plugins/danmu/index.css +603 -0
  201. package/es/plugins/danmu/index.d.ts +96 -0
  202. package/es/plugins/danmu/index.js +313 -0
  203. package/es/plugins/danmu/index.scss +356 -0
  204. package/es/plugins/definition/index.css +4 -0
  205. package/es/plugins/definition/index.d.ts +38 -0
  206. package/es/plugins/definition/index.js +164 -0
  207. package/es/plugins/definition/index.scss +4 -0
  208. package/es/plugins/download/index.css +13 -0
  209. package/es/plugins/download/index.d.ts +31 -0
  210. package/es/plugins/download/index.js +107 -0
  211. package/es/plugins/download/index.scss +22 -0
  212. package/es/plugins/dynamicBg/index.css +16 -0
  213. package/es/plugins/dynamicBg/index.d.ts +83 -0
  214. package/es/plugins/dynamicBg/index.js +316 -0
  215. package/es/plugins/dynamicBg/index.scss +19 -0
  216. package/es/plugins/enter/index.css +104 -0
  217. package/es/plugins/enter/index.d.ts +19 -0
  218. package/es/plugins/enter/index.js +46 -0
  219. package/es/plugins/enter/index.scss +78 -0
  220. package/es/plugins/error/index.css +29 -0
  221. package/es/plugins/error/index.d.ts +8 -0
  222. package/es/plugins/error/index.js +75 -0
  223. package/es/plugins/error/index.scss +34 -0
  224. package/es/plugins/fpsDetect/index.d.ts +34 -0
  225. package/es/plugins/fpsDetect/index.js +149 -0
  226. package/es/plugins/fullscreen/backicon.d.ts +17 -0
  227. package/es/plugins/fullscreen/backicon.js +72 -0
  228. package/es/plugins/fullscreen/index.css +23 -0
  229. package/es/plugins/fullscreen/index.d.ts +58 -0
  230. package/es/plugins/fullscreen/index.js +202 -0
  231. package/es/plugins/fullscreen/index.scss +35 -0
  232. package/es/plugins/gapJump/index.d.ts +21 -0
  233. package/es/plugins/gapJump/index.js +142 -0
  234. package/es/plugins/keyboard/index.d.ts +89 -0
  235. package/es/plugins/keyboard/index.js +421 -0
  236. package/es/plugins/loading/index.css +58 -0
  237. package/es/plugins/loading/index.d.ts +11 -0
  238. package/es/plugins/loading/index.js +43 -0
  239. package/es/plugins/loading/index.scss +70 -0
  240. package/es/plugins/logger/index.d.ts +54 -0
  241. package/es/plugins/logger/index.js +311 -0
  242. package/es/plugins/miniScreen/index.css +179 -0
  243. package/es/plugins/miniScreen/index.d.ts +68 -0
  244. package/es/plugins/miniScreen/index.js +212 -0
  245. package/es/plugins/miniScreen/index.scss +198 -0
  246. package/es/plugins/miniScreen/miniScreenIcon.d.ts +11 -0
  247. package/es/plugins/miniScreen/miniScreenIcon.js +56 -0
  248. package/es/plugins/mobile/index.css +181 -0
  249. package/es/plugins/mobile/index.d.ts +125 -0
  250. package/es/plugins/mobile/index.js +631 -0
  251. package/es/plugins/mobile/index.scss +180 -0
  252. package/es/plugins/mobile/touch.d.ts +43 -0
  253. package/es/plugins/mobile/touch.js +214 -0
  254. package/es/plugins/netAdaption/index.d.ts +5 -0
  255. package/es/plugins/pc/index.css +3 -0
  256. package/es/plugins/pc/index.d.ts +14 -0
  257. package/es/plugins/pc/index.js +199 -0
  258. package/es/plugins/pc/index.scss +5 -0
  259. package/es/plugins/pip/index.css +12 -0
  260. package/es/plugins/pip/index.d.ts +37 -0
  261. package/es/plugins/pip/index.js +222 -0
  262. package/es/plugins/pip/index.scss +21 -0
  263. package/es/plugins/play/index.css +12 -0
  264. package/es/plugins/play/index.d.ts +23 -0
  265. package/es/plugins/play/index.js +127 -0
  266. package/es/plugins/play/index.scss +18 -0
  267. package/es/plugins/playNext/index.css +22 -0
  268. package/es/plugins/playNext/index.d.ts +19 -0
  269. package/es/plugins/playNext/index.js +104 -0
  270. package/es/plugins/playNext/index.scss +35 -0
  271. package/es/plugins/playbackRate/index.css +4 -0
  272. package/es/plugins/playbackRate/index.d.ts +31 -0
  273. package/es/plugins/playbackRate/index.js +140 -0
  274. package/es/plugins/playbackRate/index.scss +6 -0
  275. package/es/plugins/poster/index.css +39 -0
  276. package/es/plugins/poster/index.d.ts +27 -0
  277. package/es/plugins/poster/index.js +109 -0
  278. package/es/plugins/poster/index.scss +56 -0
  279. package/es/plugins/progress/index.css +234 -0
  280. package/es/plugins/progress/index.d.ts +178 -0
  281. package/es/plugins/progress/index.js +687 -0
  282. package/es/plugins/progress/index.scss +288 -0
  283. package/es/plugins/progress/innerList.d.ts +49 -0
  284. package/es/plugins/progress/innerList.js +285 -0
  285. package/es/plugins/progress/miniProgress.d.ts +9 -0
  286. package/es/plugins/progress/miniProgress.js +55 -0
  287. package/es/plugins/progressPreview/dotsApi.d.ts +1 -0
  288. package/es/plugins/progressPreview/dotsApi.js +269 -0
  289. package/es/plugins/progressPreview/index.css +190 -0
  290. package/es/plugins/progressPreview/index.d.ts +87 -0
  291. package/es/plugins/progressPreview/index.js +475 -0
  292. package/es/plugins/progressPreview/index.scss +235 -0
  293. package/es/plugins/prompt/index.css +47 -0
  294. package/es/plugins/prompt/index.d.ts +24 -0
  295. package/es/plugins/prompt/index.js +110 -0
  296. package/es/plugins/prompt/index.scss +53 -0
  297. package/es/plugins/replay/index.css +33 -0
  298. package/es/plugins/replay/index.d.ts +16 -0
  299. package/es/plugins/replay/index.js +109 -0
  300. package/es/plugins/replay/index.scss +41 -0
  301. package/es/plugins/rotate/index.css +0 -0
  302. package/es/plugins/rotate/index.d.ts +22 -0
  303. package/es/plugins/rotate/index.js +148 -0
  304. package/es/plugins/rotate/index.scss +0 -0
  305. package/es/plugins/rotate/index2.js +2 -0
  306. package/es/plugins/screenShot/index.css +3 -0
  307. package/es/plugins/screenShot/index.d.ts +30 -0
  308. package/es/plugins/screenShot/index.js +178 -0
  309. package/es/plugins/screenShot/index.scss +5 -0
  310. package/es/plugins/start/index.css +91 -0
  311. package/es/plugins/start/index.d.ts +41 -0
  312. package/es/plugins/start/index.js +267 -0
  313. package/es/plugins/start/index.scss +115 -0
  314. package/es/plugins/stats/index.d.ts +38 -0
  315. package/es/plugins/stats/index.js +194 -0
  316. package/es/plugins/testspeed/index.d.ts +26 -0
  317. package/es/plugins/testspeed/index.js +207 -0
  318. package/es/plugins/time/index.css +46 -0
  319. package/es/plugins/time/index.d.ts +28 -0
  320. package/es/plugins/time/index.js +225 -0
  321. package/es/plugins/time/index.scss +57 -0
  322. package/es/plugins/time/timesegments.d.ts +24 -0
  323. package/es/plugins/time/timesegments.js +216 -0
  324. package/es/plugins/track/index.css +91 -0
  325. package/es/plugins/track/index.d.ts +132 -0
  326. package/es/plugins/track/index.js +463 -0
  327. package/es/plugins/track/index.scss +111 -0
  328. package/es/plugins/track/nativeSubTitle.d.ts +22 -0
  329. package/es/plugins/track/nativeSubTitle.js +94 -0
  330. package/es/plugins/volume/index.css +95 -0
  331. package/es/plugins/volume/index.d.ts +88 -0
  332. package/es/plugins/volume/index.js +319 -0
  333. package/es/plugins/volume/index.scss +124 -0
  334. package/es/plugins/waitingTimeoutJump/index.d.ts +15 -0
  335. package/es/plugins/waitingTimeoutJump/index.js +88 -0
  336. package/es/presets/default-en.d.ts +33 -0
  337. package/es/presets/default-en.js +63 -0
  338. package/es/presets/default.d.ts +34 -0
  339. package/es/presets/default.js +70 -0
  340. package/es/presets/index.d.ts +4 -0
  341. package/es/presets/live.d.ts +94 -0
  342. package/es/presets/live.js +39 -0
  343. package/es/presets/mobile.d.ts +103 -0
  344. package/es/presets/mobile.js +34 -0
  345. package/es/simple_player.js +1 -1
  346. package/es/simple_player.js.map +1 -1
  347. package/es/state.d.ts +11 -0
  348. package/es/state.js +12 -0
  349. package/es/stateClassMap.d.ts +32 -0
  350. package/es/stateClassMap.js +32 -0
  351. package/es/style/common/animation.scss +16 -0
  352. package/es/style/common/svg-url.scss +70 -0
  353. package/es/style/common.scss +457 -0
  354. package/es/style/index.scss +4 -0
  355. package/es/style/variable.scss +76 -0
  356. package/es/utils/database.d.ts +31 -0
  357. package/es/utils/database.js +107 -0
  358. package/es/utils/debug.d.ts +10 -0
  359. package/es/utils/debug.js +43 -0
  360. package/es/utils/draggabilly.d.ts +54 -0
  361. package/es/utils/draggabilly.js +410 -0
  362. package/es/utils/sniffer.d.ts +28 -0
  363. package/es/utils/sniffer.js +150 -0
  364. package/es/utils/url.d.ts +1 -0
  365. package/es/utils/util.d.ts +304 -0
  366. package/es/utils/util.js +827 -0
  367. package/es/utils/xgplayerTimeRange.d.ts +7 -0
  368. package/es/utils/xgplayerTimeRange.js +25 -0
  369. package/es/version.d.ts +2 -0
  370. package/es/version.js +2 -0
  371. package/package.json +2 -3
@@ -0,0 +1,132 @@
1
+ export default class TextTrack extends OptionsIcon {
2
+ /**
3
+ * @type ITextTrackConfig
4
+ */
5
+ static get defaultConfig(): ITextTrackConfig;
6
+ beforeCreate(args: any): void;
7
+ curIndex: any;
8
+ lastIndex: any;
9
+ _nativeTracks: any;
10
+ handlerClickSwitch: any;
11
+ /**
12
+ * @description 初始化原生字幕
13
+ *
14
+ */
15
+ _initNativeSubtitle(): void;
16
+ subTitles: any;
17
+ /**
18
+ * 初始化外挂字幕
19
+ * @param {number} defaultIndex
20
+ */
21
+ _initExtSubTitle(defaultIndex: number): void;
22
+ _renderList(list: any, isDefaultOpen: any, defaultIndex: any): void;
23
+ registerIcons(): {
24
+ textTrackOpen: {
25
+ icon: string;
26
+ class: string;
27
+ };
28
+ textTrackClose: {
29
+ icon: string;
30
+ class: string;
31
+ };
32
+ };
33
+ _onOff: () => void;
34
+ _onChange: (data: any) => void;
35
+ _onListReset: (data: any) => void;
36
+ getSubTitleIndex(list: any, subtitle?: {
37
+ id: string;
38
+ language: string;
39
+ }): number;
40
+ /**
41
+ *
42
+ * @param { Array<SubTitleItem> } list
43
+ * @param { boolean } needRemove 是否移除原来的字幕
44
+ */
45
+ updateSubtitles(list?: Array<SubTitleItem>, needRemove?: boolean): void;
46
+ updateList(data?: {}): void;
47
+ /**
48
+ *
49
+ * @param {{
50
+ * language?: string | number,
51
+ * id?: number | string,
52
+ * }} subtitle
53
+ * @returns
54
+ */
55
+ switchSubTitle(subtitle?: {
56
+ language?: string | number;
57
+ id?: number | string;
58
+ }): void;
59
+ /**
60
+ * 关闭字幕
61
+ */
62
+ switchOffSubtitle(e: any): void;
63
+ switchOnSubtitle(): void;
64
+ /**
65
+ * 切换按钮状态
66
+ * @param {boolean} isopen
67
+ */
68
+ switchIconState(isopen: boolean): void;
69
+ clickSwitch: (e: any, data: any) => void;
70
+ onItemClick(e: any, data: any, ...args: any[]): void;
71
+ updateCurItem(cIndex: any, subtitle: any): void;
72
+ renderItemList(): void;
73
+ onPlayerFocus: (e: any) => void;
74
+ onPlayerBlur: (e: any) => void;
75
+ rePosition(): void;
76
+ }
77
+ export type ListItem = {
78
+ start: number;
79
+ end: number;
80
+ list: {
81
+ [propName: string]: any;
82
+ start: number;
83
+ end: number;
84
+ text: string[];
85
+ index?: number;
86
+ }[];
87
+ };
88
+ export type SubTitleItem = {
89
+ language?: string | number;
90
+ id?: number | string;
91
+ isDefault?: boolean;
92
+ text?: any;
93
+ url?: string;
94
+ stringContent?: string;
95
+ list?: {
96
+ [propName: string]: any;
97
+ start: number;
98
+ end: number;
99
+ list: Array<ListItem>;
100
+ }[];
101
+ };
102
+ export type ITextTrackConfig = {
103
+ [propName: string]: any;
104
+ position?: string;
105
+ index?: number;
106
+ list?: Array<SubTitleItem>;
107
+ isDefaultOpen?: boolean;
108
+ style?: {
109
+ follow: boolean | null;
110
+ mode?: 'stroke' | 'bg';
111
+ followBottom?: number;
112
+ fitVideo?: boolean;
113
+ offsetBottom?: number;
114
+ baseSizeX?: number;
115
+ baseSizeY?: number;
116
+ minSize?: number;
117
+ minMobileSize?: number;
118
+ line?: 'double' | 'single' | 'three';
119
+ fontColor?: string;
120
+ };
121
+ closeText?: {
122
+ text: string;
123
+ iconText: string;
124
+ };
125
+ className?: string;
126
+ hidePortrait?: boolean;
127
+ isShowIcon?: boolean;
128
+ updateMode?: 'live' | 'vod';
129
+ renderMode?: 'normal';
130
+ debugger?: boolean;
131
+ };
132
+ import OptionsIcon from "../common/optionsIcon";
@@ -0,0 +1,463 @@
1
+ import { inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, objectSpread2 as _objectSpread2, get as _get, getPrototypeOf as _getPrototypeOf } from "../../_virtual/_rollupPluginBabelHelpers.js";
2
+ import SubTitles from "xgplayer-subtitles";
3
+ import util from "../../utils/util.js";
4
+ import { PLAYER_FOCUS, PLAYER_BLUR } from "../../events.js";
5
+ import "../../utils/debug.js";
6
+ import { POSITIONS } from "../../plugin/plugin.js";
7
+ import OptionsIcon from "../common/optionsIcon.js";
8
+ import NativeSubTitle from "./nativeSubTitle.js";
9
+ var DEFAULT_TYPE = {
10
+ CLOSE: "close",
11
+ OPEN: "open",
12
+ TEXT_CLOSE: "text-close"
13
+ };
14
+ function formatList(list) {
15
+ var defaultIndex = -1;
16
+ list.forEach(function(item, index) {
17
+ if (!item.id && !item.language) {
18
+ item.id = index;
19
+ }
20
+ item.id = String(item.id);
21
+ !item.url && (item.url = item.src);
22
+ !item.text && (item.text = item.label);
23
+ !item.language && (item.language = item.srclang);
24
+ item.isDefault === void 0 && (item.isDefault = item.default || false);
25
+ if (item.isDefault || item.default) {
26
+ if (defaultIndex < 0) {
27
+ defaultIndex = index;
28
+ } else {
29
+ item.isDefault = item.default = false;
30
+ }
31
+ }
32
+ });
33
+ return defaultIndex;
34
+ }
35
+ function checkIsSame(src, dist) {
36
+ var isIdS = util.isNotNull(src.id) && util.isNotNull(dist.id) && src.id === dist.id;
37
+ var isLS = util.isNotNull(src.language) && util.isNotNull(dist.language) && src.language === dist.language;
38
+ return isIdS || isLS;
39
+ }
40
+ var TextTrack = /* @__PURE__ */ function(_OptionsIcon) {
41
+ _inherits(TextTrack2, _OptionsIcon);
42
+ var _super = _createSuper(TextTrack2);
43
+ function TextTrack2() {
44
+ var _this;
45
+ _classCallCheck(this, TextTrack2);
46
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
+ args[_key] = arguments[_key];
48
+ }
49
+ _this = _super.call.apply(_super, [this].concat(args));
50
+ _defineProperty(_assertThisInitialized(_this), "_onOff", function() {
51
+ _this.switchOffSubtitle();
52
+ });
53
+ _defineProperty(_assertThisInitialized(_this), "_onChange", function(data) {
54
+ var _curIndex = _this.getSubTitleIndex(_this.config.list, data);
55
+ if (_curIndex < 0) {
56
+ return;
57
+ }
58
+ _this.updateCurItem(_curIndex, data);
59
+ });
60
+ _defineProperty(_assertThisInitialized(_this), "_onListReset", function(data) {
61
+ _this.updateList(data);
62
+ });
63
+ _defineProperty(_assertThisInitialized(_this), "clickSwitch", function(e, data) {
64
+ var isActionClose = data.type === DEFAULT_TYPE.CLOSE || data.type === DEFAULT_TYPE.TEXT_CLOSE;
65
+ if (_this.subTitles) {
66
+ if (isActionClose) {
67
+ _this.subTitles.switchOff();
68
+ } else {
69
+ _this.switchSubTitle({
70
+ language: data.language,
71
+ id: data.id
72
+ });
73
+ }
74
+ }
75
+ });
76
+ _defineProperty(_assertThisInitialized(_this), "onIconClick", function(e) {
77
+ if (_this.curItem) {
78
+ _this.subTitles.switchOff();
79
+ } else {
80
+ _this.switchOnSubtitle(e);
81
+ }
82
+ });
83
+ _defineProperty(_assertThisInitialized(_this), "onPlayerFocus", function(e) {
84
+ if (!_this.subTitles || !_this.config.style.follow) {
85
+ return;
86
+ }
87
+ _this.rePosition();
88
+ });
89
+ _defineProperty(_assertThisInitialized(_this), "onPlayerBlur", function(e) {
90
+ if (!_this.subTitles || !_this.config.style.follow || _this.playerConfig.marginControls) {
91
+ return;
92
+ }
93
+ _this.subTitles.root && (_this.subTitles.root.style.transform = "translate(0, 0)");
94
+ });
95
+ return _this;
96
+ }
97
+ _createClass(TextTrack2, [{
98
+ key: "beforeCreate",
99
+ value: function beforeCreate(args) {
100
+ var texttrack = args.player.config.texttrack || args.player.config.textTrack;
101
+ if (util.typeOf(texttrack) === "Array") {
102
+ args.config.list = texttrack;
103
+ }
104
+ }
105
+ }, {
106
+ key: "afterCreate",
107
+ value: function afterCreate() {
108
+ var _this$config = this.config, list = _this$config.list, mode = _this$config.mode;
109
+ var defaultIndex = formatList(list);
110
+ _get(_getPrototypeOf(TextTrack2.prototype), "afterCreate", this).call(this);
111
+ this.curIndex = -1;
112
+ this.lastIndex = -1;
113
+ this.curItem = null;
114
+ this._nativeTracks = null;
115
+ this.handlerClickSwitch = this.hook("subtitle_change", this.clickSwitch);
116
+ if (mode === "native") {
117
+ this._initNativeSubtitle();
118
+ } else {
119
+ this._initExtSubTitle(defaultIndex);
120
+ }
121
+ }
122
+ }, {
123
+ key: "_initNativeSubtitle",
124
+ value: function _initNativeSubtitle() {
125
+ var player = this.player;
126
+ if (!player._subTitles) {
127
+ player._subTitles = new NativeSubTitle(player.media);
128
+ }
129
+ this.subTitles = player._subTitles;
130
+ this.subTitles.on("off", this._onOff);
131
+ this.subTitles.on("change", this._onChange);
132
+ this.subTitles.on("reset", this._onListReset);
133
+ }
134
+ }, {
135
+ key: "_initExtSubTitle",
136
+ value: function _initExtSubTitle(defaultIndex) {
137
+ var _this$config2 = this.config, list = _this$config2.list, style = _this$config2.style, isDefaultOpen = _this$config2.isDefaultOpen, updateMode = _this$config2.updateMode, renderMode = _this$config2.renderMode;
138
+ if (isDefaultOpen && defaultIndex < 0 && list.length > 0) {
139
+ defaultIndex = 0;
140
+ list[0].isDefault = true;
141
+ }
142
+ var config = {
143
+ subTitles: list,
144
+ defaultOpen: isDefaultOpen,
145
+ updateMode,
146
+ renderMode,
147
+ debugger: this.config.debugger
148
+ };
149
+ Object.keys(style).map(function(key) {
150
+ config[key] = style[key];
151
+ });
152
+ var _needPos = !this.playerConfig.marginControls && this.player.controls.root;
153
+ if (_needPos) {
154
+ this.on(PLAYER_FOCUS, this.onPlayerFocus);
155
+ this.on(PLAYER_BLUR, this.onPlayerBlur);
156
+ }
157
+ var player = this.player;
158
+ if (!player._subTitles) {
159
+ player._subTitles = new SubTitles(config);
160
+ player._subTitles.attachPlayer(this.player);
161
+ } else {
162
+ player._subTitles._isOpen && (defaultIndex = this.getSubTitleIndex(this.config.list, player._subTitles.currentText));
163
+ }
164
+ this.subTitles = player._subTitles;
165
+ this.subTitles.on("off", this._onOff);
166
+ this.subTitles.on("change", this._onChange);
167
+ this.subTitles.on("reset", this._onListReset);
168
+ if (style.follow && this.subTitles.root) {
169
+ util.addClass(this.subTitles.root, "follow-control");
170
+ }
171
+ this._renderList(list, isDefaultOpen, defaultIndex);
172
+ }
173
+ }, {
174
+ key: "_renderList",
175
+ value: function _renderList(list, isDefaultOpen, defaultIndex) {
176
+ if (!list || list.length === 0) {
177
+ return;
178
+ }
179
+ if (isDefaultOpen) {
180
+ defaultIndex = defaultIndex < 0 ? 0 : defaultIndex;
181
+ list[defaultIndex].isDefault = true;
182
+ this.curIndex = defaultIndex;
183
+ this.curItem = list[defaultIndex];
184
+ this.switchIconState(true);
185
+ } else {
186
+ this.switchIconState(false);
187
+ }
188
+ if (this.player.isCanplay && list.length > 0) {
189
+ this.renderItemList(list);
190
+ this.show();
191
+ }
192
+ }
193
+ }, {
194
+ key: "registerIcons",
195
+ value: function registerIcons() {
196
+ return {
197
+ textTrackOpen: {
198
+ icon: "",
199
+ class: "xg-texttrak-open"
200
+ },
201
+ textTrackClose: {
202
+ icon: "",
203
+ class: "xg-texttrak-close"
204
+ }
205
+ };
206
+ }
207
+ }, {
208
+ key: "show",
209
+ value: function show() {
210
+ if (!this.config.list || this.config.list.length < 1) {
211
+ return;
212
+ }
213
+ util.addClass(this.root, "show");
214
+ }
215
+ }, {
216
+ key: "getSubTitleIndex",
217
+ value: function getSubTitleIndex(list) {
218
+ var subtitle = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
219
+ id: "",
220
+ language: ""
221
+ };
222
+ var cIndex = -1;
223
+ if (!subtitle || !subtitle.id && !subtitle.language) {
224
+ return cIndex;
225
+ }
226
+ list.forEach(function(item, index) {
227
+ if (checkIsSame(item, subtitle)) {
228
+ cIndex = index;
229
+ }
230
+ });
231
+ return cIndex;
232
+ }
233
+ }, {
234
+ key: "updateSubtitles",
235
+ value: function updateSubtitles() {
236
+ var list = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
237
+ var needRemove = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
238
+ if (!list) {
239
+ return;
240
+ }
241
+ this.updateList({
242
+ list
243
+ });
244
+ this.subTitles && this.subTitles.setSubTitles(this.config.list, this.curIndex > -1, needRemove);
245
+ }
246
+ }, {
247
+ key: "updateList",
248
+ value: function updateList() {
249
+ var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
250
+ if (!data.list) {
251
+ return;
252
+ }
253
+ var nList = [];
254
+ data.list.forEach(function(item) {
255
+ nList.push(item);
256
+ });
257
+ var defaultIndex = formatList(nList);
258
+ if (data.isOpen) {
259
+ this.curIndex = defaultIndex;
260
+ this.curItem = defaultIndex > -1 ? nList[defaultIndex] : null;
261
+ } else {
262
+ this.curIndex = -1;
263
+ this.curItem = null;
264
+ }
265
+ this.config.list = nList;
266
+ if (nList.length > 0) {
267
+ this.show();
268
+ } else {
269
+ this.switchOffSubtitle();
270
+ this.hide();
271
+ }
272
+ this.renderItemList();
273
+ }
274
+ }, {
275
+ key: "switchSubTitle",
276
+ value: function switchSubTitle() {
277
+ var subtitle = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
278
+ id: "",
279
+ language: ""
280
+ };
281
+ this.switchIconState(true);
282
+ var cIndex = this.getSubTitleIndex(this.config.list, subtitle);
283
+ if (cIndex < 0) {
284
+ return;
285
+ }
286
+ this.subTitles.switch(subtitle).catch(function(e) {
287
+ });
288
+ }
289
+ }, {
290
+ key: "switchOffSubtitle",
291
+ value: function switchOffSubtitle(e) {
292
+ this.emit("subtitle_change", {
293
+ off: true,
294
+ isListUpdate: false,
295
+ list: []
296
+ });
297
+ this.lastIndex = this.curIndex;
298
+ this.curIndex = -1;
299
+ this.curItem = null;
300
+ this.switchIconState(false);
301
+ this.renderItemList();
302
+ }
303
+ }, {
304
+ key: "switchOnSubtitle",
305
+ value: function switchOnSubtitle() {
306
+ var list = this.config.list;
307
+ var _sub = this.lastIndex > -1 ? this.lastIndex : 0;
308
+ var _item = list[_sub];
309
+ this.switchIconState(true);
310
+ this.switchSubTitle(_item);
311
+ }
312
+ }, {
313
+ key: "switchIconState",
314
+ value: function switchIconState(isopen) {
315
+ this.setAttr("data-state", isopen ? "open" : "close");
316
+ }
317
+ }, {
318
+ key: "onItemClick",
319
+ value: function onItemClick(e, data) {
320
+ var target = e.delegateTarget;
321
+ var language = target.getAttribute("language");
322
+ var id = target.getAttribute("data-id");
323
+ var type = target.getAttribute("data-type");
324
+ _get(_getPrototypeOf(TextTrack2.prototype), "onItemClick", this).apply(this, arguments);
325
+ this.handlerClickSwitch(e, {
326
+ language,
327
+ id,
328
+ type
329
+ });
330
+ }
331
+ }, {
332
+ key: "changeCurrentText",
333
+ value: function changeCurrentText() {
334
+ if (this.isIcons) {
335
+ return;
336
+ }
337
+ var _this$config3 = this.config, list = _this$config3.list, closeText = _this$config3.closeText;
338
+ var index = this.curIndex;
339
+ if (index - 1 < 0) {
340
+ this.find(".icon-text").innerHTML = this.getTextByLang(closeText, "iconText");
341
+ } else if (index - 1 < list.length) {
342
+ var curItem = list[index - 1];
343
+ if (!curItem)
344
+ return;
345
+ this.find(".icon-text").innerHTML = this.getTextByLang(curItem, "iconText");
346
+ }
347
+ }
348
+ }, {
349
+ key: "updateCurItem",
350
+ value: function updateCurItem(cIndex, subtitle) {
351
+ this.curIndex = cIndex;
352
+ this.curItem = this.config.list[cIndex - 1];
353
+ this.renderItemList();
354
+ this.emit("subtitle_change", _objectSpread2({
355
+ off: false,
356
+ isListUpdate: false,
357
+ list: []
358
+ }, subtitle));
359
+ }
360
+ }, {
361
+ key: "renderItemList",
362
+ value: function renderItemList() {
363
+ var _this2 = this;
364
+ var _this$config4 = this.config, list = _this$config4.list, closeText = _this$config4.closeText, needCloseText = _this$config4.needCloseText;
365
+ var items = [];
366
+ var cIndex = this.curIndex;
367
+ var _curI = this.curIndex;
368
+ if (needCloseText) {
369
+ items.push({
370
+ showText: this.getTextByLang(closeText),
371
+ "data-type": DEFAULT_TYPE.TEXT_CLOSE,
372
+ selected: this.curIndex === -1
373
+ });
374
+ cIndex++;
375
+ }
376
+ list.map(function(item, index) {
377
+ var itemInfo = {
378
+ language: item.language || item.srclang || "",
379
+ "data-id": item.id || ""
380
+ };
381
+ itemInfo.selected = _this2.curIndex === index;
382
+ itemInfo.showText = _this2.getTextByLang(item);
383
+ items.push(itemInfo);
384
+ });
385
+ _get(_getPrototypeOf(TextTrack2.prototype), "renderItemList", this).call(this, items, cIndex);
386
+ this.curIndex = _curI;
387
+ this.curItem = list[_curI];
388
+ }
389
+ }, {
390
+ key: "rePosition",
391
+ value: function rePosition() {
392
+ var fitVideo = this.config.style.fitVideo;
393
+ var _rect = this.player.controls.root.getBoundingClientRect();
394
+ var cHeight = 0 - _rect.height;
395
+ if (!fitVideo) {
396
+ this.subTitles.root.style.transform = "translate(0, ".concat(cHeight, "px)");
397
+ return;
398
+ }
399
+ var _this$player = this.player, video = _this$player.video, root = _this$player.root;
400
+ var _root$getBoundingClie = root.getBoundingClientRect(), height = _root$getBoundingClie.height, width = _root$getBoundingClie.width;
401
+ var videoHeight = video.videoHeight, videoWidth = video.videoWidth;
402
+ var pi = parseInt(videoHeight / videoWidth * 100, 10);
403
+ var vHeight = pi * width / 100;
404
+ if (vHeight > height) {
405
+ vHeight = height;
406
+ }
407
+ var margin = (height - vHeight) / 2 - cHeight;
408
+ if (margin < 0) {
409
+ this.subTitles.root.style.transform = "translate(0, ".concat(margin, "px)");
410
+ }
411
+ }
412
+ }, {
413
+ key: "destroy",
414
+ value: function destroy() {
415
+ if (this.subTitles) {
416
+ this.subTitles.destroy();
417
+ this.subTitles = null;
418
+ }
419
+ _get(_getPrototypeOf(TextTrack2.prototype), "destroy", this).call(this);
420
+ }
421
+ }], [{
422
+ key: "pluginName",
423
+ get: function get() {
424
+ return "texttrack";
425
+ }
426
+ }, {
427
+ key: "defaultConfig",
428
+ get: function get() {
429
+ return _objectSpread2(_objectSpread2({}, OptionsIcon.defaultConfig), {}, {
430
+ position: POSITIONS.CONTROLS_RIGHT,
431
+ index: 6,
432
+ list: [],
433
+ isDefaultOpen: true,
434
+ style: {
435
+ follow: true,
436
+ mode: "stroke",
437
+ followBottom: 50,
438
+ fitVideo: true,
439
+ offsetBottom: 2,
440
+ baseSizeX: 49,
441
+ baseSizeY: 28,
442
+ minSize: 16,
443
+ minMobileSize: 13,
444
+ line: "double",
445
+ fontColor: "#fff"
446
+ },
447
+ closeText: {
448
+ text: "\u4E0D\u5F00\u542F",
449
+ iconText: "\u5B57\u5E55"
450
+ },
451
+ needCloseText: true,
452
+ className: "xgplayer-texttrack",
453
+ hidePortrait: false,
454
+ isShowIcon: true,
455
+ renderMode: "normal",
456
+ mode: "external",
457
+ debugger: false
458
+ });
459
+ }
460
+ }]);
461
+ return TextTrack2;
462
+ }(OptionsIcon);
463
+ export { TextTrack as default };
@@ -0,0 +1,111 @@
1
+ .xgplayer-texttrack[data-state=open]{
2
+ .xg-texttrak-open {
3
+ display: block;
4
+ }
5
+
6
+ .xg-texttrak-close {
7
+ display: none;
8
+ }
9
+ }
10
+
11
+ .xgplayer-texttrack[data-state=close]{
12
+ .xg-texttrak-open {
13
+ display: none;
14
+ }
15
+
16
+ .xg-texttrak-close {
17
+ display: block;
18
+ }
19
+ }
20
+
21
+ .xgplayer-texttrack-active {
22
+ .xgplayer-texttrack {
23
+ ul {
24
+ display: block;
25
+ }
26
+ }
27
+ }
28
+
29
+ .xgplayer xg-text-track.follow-control {
30
+ transition: transform .2s ease;
31
+ }
32
+
33
+ .xgplayer-is-texttrack {
34
+ .xgplayer-texttrack {
35
+ display: block;
36
+ }
37
+ }
38
+
39
+
40
+ // // 外挂字幕的dom样式
41
+ xg-text-track.xg-text-track {
42
+ font-family: "PingFang SC","SF Pro SC","SF Pro Text","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
43
+ -webkit-font-smoothing: antialiased;
44
+ position: absolute;
45
+ bottom: 0;
46
+ color: #fff;
47
+ left: 0;
48
+ right: 0;
49
+ pointer-events: none;
50
+ display: flex;
51
+ justify-content: center;
52
+ &.text-track-no-fitvideo {
53
+ margin-bottom: 2%;
54
+ }
55
+ &.text-track-hide {
56
+ opacity: 0;
57
+ visibility: hidden;
58
+ }
59
+ &.text-track-show {
60
+ opacity: 1;
61
+ visibility: visible;
62
+ }
63
+
64
+ xg-text-track-inner {
65
+ display: block;
66
+ max-width: 92%;
67
+ text-align: center;
68
+ }
69
+ xg-text-track-span {
70
+ display: -webkit-box;
71
+ text-align: left;
72
+ text-overflow: ellipsis;
73
+ -webkit-box-orient: vertical;
74
+ overflow: hidden;
75
+ padding: 1px 4px;
76
+ -webkit-line-clamp: 1;
77
+ line-height: 120%;
78
+ word-break: break-word;
79
+ &.text-track-deputy {
80
+ font-size: 75%;
81
+ }
82
+ &.text-track-single{
83
+ -webkit-line-clamp: 1;
84
+ }
85
+ &.text-track-double {
86
+ -webkit-line-clamp: 2;
87
+ }
88
+ &.text-track-three{
89
+ -webkit-line-clamp: 3;
90
+ }
91
+ &.text-track-space {
92
+ opacity: 0;
93
+ height: 0;
94
+ line-height: 0;
95
+ }
96
+ }
97
+
98
+ &.text-track-bg {
99
+ xg-text-track-inner {
100
+ background-color: rgba(0, 0, 0, .54);
101
+ border-radius: 2px;
102
+ }
103
+ }
104
+ &.text-track-stroke {
105
+ xg-text-track-inner{
106
+ background-color: none;
107
+ border-radius: 0;
108
+ text-shadow: -1px 1px 0 rgba(0,0,0,0.7), 1px 1px 0 rgba(0,0,0,0.7), 1px -1px 0 rgba(0,0,0,0.7), -1px -1px 0 rgba(0,0,0,0.7);
109
+ }
110
+ }
111
+ }