xgplayer 2.32.2 → 2.32.3

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 (188) hide show
  1. package/browser/controls/danmu.js +3 -1
  2. package/browser/controls/errorRetry.js +1 -1
  3. package/browser/controls/nativeTextTrack.js +1 -1
  4. package/browser/core_player.js +1 -1
  5. package/browser/core_player.js.map +1 -1
  6. package/browser/index.js +7 -5
  7. package/browser/index.js.map +1 -1
  8. package/browser/simple_player.js +1 -1
  9. package/browser/simple_player.js.map +1 -1
  10. package/dist/controls/danmu.js +3 -1
  11. package/dist/controls/errorRetry.js +1 -1
  12. package/dist/controls/nativeTextTrack.js +1 -1
  13. package/dist/core_player.js +6 -7
  14. package/dist/core_player.js.map +1 -1
  15. package/dist/index.js +2881 -1887
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.min.css +1 -0
  18. package/dist/index.min.js +2 -0
  19. package/dist/index.min.js.map +1 -0
  20. package/dist/simple_player.js +6 -7
  21. package/dist/simple_player.js.map +1 -1
  22. package/es/controls/danmu.js +3 -1
  23. package/es/controls/errorRetry.js +1 -1
  24. package/es/controls/nativeTextTrack.js +1 -1
  25. package/es/core_player.js +1 -1
  26. package/es/core_player.js.map +1 -1
  27. package/es/index.js +7 -5
  28. package/es/index.js.map +1 -1
  29. package/es/simple_player.js +1 -1
  30. package/es/simple_player.js.map +1 -1
  31. package/package.json +11 -2
  32. package/types/index.d.ts +0 -11
  33. package/postcss.config.js +0 -7
  34. package/src/bind/airplay.js +0 -10
  35. package/src/bind/cssFullscreen.js +0 -10
  36. package/src/bind/danmu.js +0 -10
  37. package/src/bind/definition.js +0 -10
  38. package/src/bind/download.js +0 -10
  39. package/src/bind/enter.js +0 -8
  40. package/src/bind/error.js +0 -8
  41. package/src/bind/errorRetry.js +0 -8
  42. package/src/bind/flex.js +0 -8
  43. package/src/bind/fullscreen.js +0 -10
  44. package/src/bind/i18n.js +0 -8
  45. package/src/bind/keyboard.js +0 -8
  46. package/src/bind/loading.js +0 -8
  47. package/src/bind/localPreview.js +0 -10
  48. package/src/bind/memoryPlay.js +0 -10
  49. package/src/bind/miniplayer.js +0 -10
  50. package/src/bind/mobile.js +0 -8
  51. package/src/bind/nativeTextTrack.js +0 -8
  52. package/src/bind/pc.js +0 -8
  53. package/src/bind/pip.js +0 -10
  54. package/src/bind/play.js +0 -10
  55. package/src/bind/playNext.js +0 -10
  56. package/src/bind/playbackRate.js +0 -8
  57. package/src/bind/poster.js +0 -8
  58. package/src/bind/progress.js +0 -8
  59. package/src/bind/reload.js +0 -10
  60. package/src/bind/replay.js +0 -10
  61. package/src/bind/rotate.js +0 -10
  62. package/src/bind/screenShot.js +0 -10
  63. package/src/bind/stallCheck.js +0 -8
  64. package/src/bind/start.js +0 -10
  65. package/src/bind/textTrack.js +0 -8
  66. package/src/bind/time.js +0 -8
  67. package/src/bind/volume.js +0 -10
  68. package/src/controls/airplay.js +0 -20
  69. package/src/controls/cssFullscreen.js +0 -49
  70. package/src/controls/danmu.js +0 -75
  71. package/src/controls/definition.js +0 -13
  72. package/src/controls/download.js +0 -28
  73. package/src/controls/errorRetry.js +0 -132
  74. package/src/controls/fullscreen.js +0 -145
  75. package/src/controls/keyboard.js +0 -214
  76. package/src/controls/localPreview.js +0 -32
  77. package/src/controls/memoryPlay.js +0 -14
  78. package/src/controls/miniplayer.js +0 -128
  79. package/src/controls/mobile.js +0 -100
  80. package/src/controls/pc.js +0 -123
  81. package/src/controls/pip.js +0 -52
  82. package/src/controls/play.js +0 -34
  83. package/src/controls/playNext.js +0 -29
  84. package/src/controls/reload.js +0 -24
  85. package/src/controls/replay.js +0 -30
  86. package/src/controls/rotate.js +0 -99
  87. package/src/controls/screenShot.js +0 -65
  88. package/src/controls/stallCheck.js +0 -38
  89. package/src/controls/start.js +0 -60
  90. package/src/controls/textTrack.js +0 -182
  91. package/src/controls/volume.js +0 -178
  92. package/src/controls.js +0 -36
  93. package/src/core_player.js +0 -13
  94. package/src/error.js +0 -74
  95. package/src/index.js +0 -57
  96. package/src/player.js +0 -553
  97. package/src/proxy.js +0 -495
  98. package/src/simple_player.js +0 -42
  99. package/src/skin/assets/airplay.svg +0 -1
  100. package/src/skin/assets/download.svg +0 -14
  101. package/src/skin/assets/exitCssFull.svg +0 -3
  102. package/src/skin/assets/exitFull.svg +0 -3
  103. package/src/skin/assets/loading.svg +0 -3
  104. package/src/skin/assets/panel.svg +0 -4
  105. package/src/skin/assets/pause.svg +0 -3
  106. package/src/skin/assets/play.svg +0 -3
  107. package/src/skin/assets/playNext.svg +0 -3
  108. package/src/skin/assets/reload.svg +0 -3
  109. package/src/skin/assets/replay.svg +0 -3
  110. package/src/skin/assets/requestCssFull.svg +0 -3
  111. package/src/skin/assets/requestFull.svg +0 -3
  112. package/src/skin/assets/rotate.svg +0 -11
  113. package/src/skin/assets/startPause.svg +0 -3
  114. package/src/skin/assets/startPlay.svg +0 -3
  115. package/src/skin/assets/volumeLarge.svg +0 -4
  116. package/src/skin/assets/volumeMuted.svg +0 -4
  117. package/src/skin/assets/volumeSmall.svg +0 -4
  118. package/src/skin/controls/airplay.js +0 -44
  119. package/src/skin/controls/cssFullscreen.js +0 -36
  120. package/src/skin/controls/danmu.js +0 -214
  121. package/src/skin/controls/definition.js +0 -251
  122. package/src/skin/controls/download.js +0 -29
  123. package/src/skin/controls/enter.js +0 -21
  124. package/src/skin/controls/error.js +0 -57
  125. package/src/skin/controls/flex.js +0 -13
  126. package/src/skin/controls/fullscreen.js +0 -43
  127. package/src/skin/controls/i18n.js +0 -168
  128. package/src/skin/controls/loading.js +0 -17
  129. package/src/skin/controls/localPreview.js +0 -18
  130. package/src/skin/controls/memoryPlay.js +0 -39
  131. package/src/skin/controls/miniplayer.js +0 -26
  132. package/src/skin/controls/nativeTextTrack.js +0 -153
  133. package/src/skin/controls/pip.js +0 -26
  134. package/src/skin/controls/play.js +0 -43
  135. package/src/skin/controls/playNext.js +0 -41
  136. package/src/skin/controls/playbackRate.js +0 -141
  137. package/src/skin/controls/poster.js +0 -18
  138. package/src/skin/controls/progress.js +0 -407
  139. package/src/skin/controls/reload.js +0 -29
  140. package/src/skin/controls/replay.js +0 -56
  141. package/src/skin/controls/rotate.js +0 -29
  142. package/src/skin/controls/screenShot.js +0 -27
  143. package/src/skin/controls/start.js +0 -62
  144. package/src/skin/controls/textTrack.js +0 -113
  145. package/src/skin/controls/time.js +0 -40
  146. package/src/skin/controls/volume.js +0 -63
  147. package/src/skin/index.js +0 -63
  148. package/src/skin/style/common/animation.scss +0 -16
  149. package/src/skin/style/common/svg-url.scss +0 -70
  150. package/src/skin/style/controls/airplay.scss +0 -35
  151. package/src/skin/style/controls/controls.scss +0 -40
  152. package/src/skin/style/controls/cssfullscreen.scss +0 -103
  153. package/src/skin/style/controls/danmu.scss +0 -333
  154. package/src/skin/style/controls/definition.scss +0 -76
  155. package/src/skin/style/controls/download.scss +0 -45
  156. package/src/skin/style/controls/enter.scss +0 -55
  157. package/src/skin/style/controls/error.scss +0 -34
  158. package/src/skin/style/controls/fullscreen.scss +0 -60
  159. package/src/skin/style/controls/icon.scss +0 -12
  160. package/src/skin/style/controls/live.scss +0 -9
  161. package/src/skin/style/controls/loading.scss +0 -44
  162. package/src/skin/style/controls/memoryPlay.scss +0 -28
  163. package/src/skin/style/controls/miniplayer.scss +0 -104
  164. package/src/skin/style/controls/pip.scss +0 -42
  165. package/src/skin/style/controls/placeholder.scss +0 -7
  166. package/src/skin/style/controls/play.scss +0 -79
  167. package/src/skin/style/controls/playNext.scss +0 -44
  168. package/src/skin/style/controls/playbackRate.scss +0 -82
  169. package/src/skin/style/controls/poster.scss +0 -19
  170. package/src/skin/style/controls/progress.scss +0 -182
  171. package/src/skin/style/controls/reload.scss +0 -43
  172. package/src/skin/style/controls/replay.scss +0 -46
  173. package/src/skin/style/controls/rotate.scss +0 -41
  174. package/src/skin/style/controls/screenShot.scss +0 -42
  175. package/src/skin/style/controls/start.scss +0 -78
  176. package/src/skin/style/controls/textTrack.scss +0 -87
  177. package/src/skin/style/controls/time.scss +0 -24
  178. package/src/skin/style/controls/tips.scss +0 -24
  179. package/src/skin/style/controls/videoProxy.scss +0 -6
  180. package/src/skin/style/controls/volume.scss +0 -143
  181. package/src/skin/style/index.scss +0 -88
  182. package/src/utils/sniffer.js +0 -47
  183. package/src/utils/url.js +0 -10
  184. package/src/utils/util.js +0 -358
  185. package/src/utils/xgplayerTimeRange.js +0 -17
  186. package/src/version.js +0 -7
  187. package/version.json +0 -3
  188. package/webpack.config.js +0 -168
@@ -1,132 +0,0 @@
1
- import Errors from '../error'
2
- /**
3
- * Error retry plugin
4
- * get config from player.config.errorConfig
5
- * The Plugin is just deal with the situation that play with video.src,
6
- * and get the http status of current video.src
7
- */
8
-
9
- const defaultConfig = {
10
- maxCount: 3, // max number of retries
11
- backupUrl: '', // the backup url for retry
12
- isFetch: true, // is need to check the cdn url statud
13
- fetchTimeout: 100 // timeout time for get cdn status
14
- }
15
-
16
- function errorRetry () {
17
- const player = this
18
- // 无设置参数或者是通过扩展播放的不做处理
19
- if (!player.config.errorConfig || player.src.indexOf('blob:') > -1) {
20
- return
21
- }
22
- const errorConfig = {}
23
- const _inConfig = player.config.errorConfig
24
- for (const key in defaultConfig) {
25
- if (_inConfig[key] === undefined) {
26
- errorConfig[key] = defaultConfig[key]
27
- } else {
28
- errorConfig[key] = _inConfig[key]
29
- }
30
- }
31
- player.retryData = {
32
- count: 0, // 重试次数
33
- errfTimer: null, // 超时设置定时器
34
- isFetchReturn: false, // fetch请求是否已经返回
35
- currentTime: 0 // 出错的时候时间
36
- }
37
-
38
- function errorfetch (player, url, timeout) {
39
- const resolveFun = (resolve, data) => {
40
- if (!player.retryData.isFetchReturn) {
41
- player.retryData.isFetchReturn = true
42
- resolve(data)
43
- }
44
- }
45
- return new Promise((resolve, reject) => {
46
- try {
47
- let xhr = new window.XMLHttpRequest()
48
- xhr.open('get', url)
49
- xhr.onload = function () {
50
- resolveFun(resolve, {status: xhr.status, statusText: xhr.statusText, xhr})
51
- }
52
- xhr.onerror = function () {
53
- resolveFun(resolve, {status: xhr.status, statusText: xhr.statusText || 'The network environment is disconnected or the address is invalid', xhr})
54
- }
55
- xhr.onabort = function () {
56
- // console.log('task onerror', xhr)
57
- }
58
- player.retryData.errfTimer = window.setTimeout(() => {
59
- let errfTimer = player.retryData.errfTimer
60
- window.clearTimeout(errfTimer)
61
- player.retryData.errfTimer = null
62
- resolveFun(resolve, {status: -1, statusText: 'request timeout'})
63
- }, timeout)
64
- xhr.send()
65
- } catch (err) {
66
- player.retryData.isFetchReturn = true
67
- resolveFun(resolve, {status: -2, statusText: 'request error'})
68
- }
69
- })
70
- }
71
-
72
- function retryCanPlay () {
73
- // console.log(`retryCanPlay this.retryData.currentTime:${this.retryData.currentTime}`)
74
- this.currentTime = this.retryData.currentTime
75
- this.play()
76
- this.retryData.retryCode = 0
77
- this.retryData.isFetchReturn = false
78
- this.retryData.currentTime = 0
79
- }
80
-
81
- const _originErrorEmit = player._onError
82
- player._onError = (data) => {
83
- const errorCount = this.retryData.count
84
- // console.log(`originErrorEmit:errorCount:${errorCount}`, data)
85
- if (errorCount > errorConfig.maxCount) {
86
- if (errorConfig.isFetch) {
87
- errorfetch(this, this.currentSrc, errorConfig.fetchTimeout).then((data) => {
88
- this.emit('error', new Errors({
89
- type: 'network',
90
- currentTime: this.currentTime,
91
- duration: this.duration || 0,
92
- networkState: this.networkState,
93
- readyState: this.readyState,
94
- currentSrc: this.currentSrc,
95
- src: this.src,
96
- ended: this.ended,
97
- httpCode: data.status,
98
- httpMsg: data.statusText,
99
- errd: {
100
- line: 101,
101
- msg: this.error,
102
- handle: 'plugin errorRetry'
103
- },
104
- errorCode: this.video && this.video.error.code,
105
- mediaError: this.video && this.video.error
106
- }));
107
- _originErrorEmit.call(this, data)
108
- })
109
- } else {
110
- _originErrorEmit.call(this, data)
111
- }
112
- return;
113
- }
114
- if (errorCount === 0) {
115
- this.retryData.currentTime = this.currentTime
116
- this.once('canplay', retryCanPlay.bind(this))
117
- }
118
- let src = ''
119
- if (errorConfig.count < 2) {
120
- src = errorConfig.backupUrl ? errorConfig.backupUrl : player.currentSrc
121
- } else {
122
- src = errorConfig.backupUrl && errorCount > 1 ? errorConfig.backupUrl : player.currentSrc
123
- }
124
- this.retryData.count++
125
- this.src = src
126
- }
127
- }
128
-
129
- export default {
130
- name: 'errorretry',
131
- method: errorRetry
132
- }
@@ -1,145 +0,0 @@
1
- import { hasClass, addClass, removeClass, PresentationMode, checkWebkitSetPresentationMode } from '../utils/util'
2
-
3
- let fullscreen = function () {
4
- let player = this
5
- let root = player.root
6
-
7
- function onFullscreenBtnClick () {
8
- if (player.config.rotateFullscreen) {
9
- if (hasClass(root, 'xgplayer-rotate-fullscreen')) {
10
- player.exitRotateFullscreen()
11
- } else {
12
- player.getRotateFullscreen()
13
- }
14
- } else {
15
- if (hasClass(root, 'xgplayer-is-fullscreen')) {
16
- player.exitFullscreen(root)
17
- } else {
18
- player.getFullscreen(root)
19
- }
20
- }
21
- }
22
- player.on('fullscreenBtnClick', onFullscreenBtnClick)
23
-
24
- function onFullscreenChange () {
25
- let fullscreenEl = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement
26
- if (fullscreenEl && fullscreenEl === root) {
27
- addClass(root, 'xgplayer-is-fullscreen')
28
- player.emit('requestFullscreen')
29
- } else if (hasClass(root, 'xgplayer-is-fullscreen')) {
30
- removeClass(root, 'xgplayer-is-fullscreen')
31
- player.emit('exitFullscreen')
32
- }
33
- if (player.danmu && typeof player.danmu.resize === 'function') {
34
- player.danmu.resize()
35
- }
36
- };
37
- ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'].forEach(item => {
38
- document.addEventListener(item, onFullscreenChange)
39
- })
40
-
41
- player.video.addEventListener('webkitbeginfullscreen', function () {
42
- addClass(root, 'xgplayer-is-fullscreen')
43
- player.emit('requestFullscreen')
44
- })
45
-
46
- player.video.addEventListener('webkitendfullscreen', function () {
47
- removeClass(root, 'xgplayer-is-fullscreen')
48
- player.emit('exitFullscreen')
49
- })
50
-
51
- function onWebkitpresentationmodechanged (e) {
52
- const mode = player.video.webkitPresentationMode
53
- // 非全屏模式 退出全屏
54
- if (mode !== PresentationMode.FULLSCREEN) {
55
- removeClass(root, 'xgplayer-is-fullscreen')
56
- player.emit('exitFullscreen')
57
- }
58
- }
59
-
60
- checkWebkitSetPresentationMode(player.video) &&
61
- player.video.addEventListener('webkitpresentationmodechanged', onWebkitpresentationmodechanged)
62
-
63
- function onDestroy () {
64
- player.off('fullscreenBtnClick', onFullscreenBtnClick);
65
- ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'].forEach(item => {
66
- document.removeEventListener(item, onFullscreenChange)
67
- })
68
-
69
- checkWebkitSetPresentationMode(player.video) &&
70
- player.video.removeEventListener('webkitpresentationmodechanged', onWebkitpresentationmodechanged)
71
-
72
- player.off('destroy', onDestroy)
73
- }
74
- player.once('destroy', onDestroy)
75
-
76
- player.getFullscreen = function (el) {
77
- let player = this
78
- if (el.requestFullscreen) {
79
- let fullscreenPromise = el.requestFullscreen()
80
- if (fullscreenPromise) {
81
- fullscreenPromise.catch(function () {
82
- player.emit('fullscreen error')
83
- })
84
- }
85
- } else if (el.mozRequestFullScreen) {
86
- el.mozRequestFullScreen()
87
- } else if (el.webkitRequestFullscreen) {
88
- el.webkitRequestFullscreen(window.Element.ALLOW_KEYBOARD_INPUT)
89
- } else if (player.video.webkitSupportsFullscreen) {
90
- player.video.webkitEnterFullscreen()
91
- } else if (el.msRequestFullscreen) {
92
- el.msRequestFullscreen()
93
- } else {
94
- addClass(el, 'xgplayer-is-cssfullscreen')
95
- }
96
- }
97
-
98
- player.exitFullscreen = function (el) {
99
- if (document.exitFullscreen) {
100
- document.exitFullscreen()
101
- } else if (document.webkitExitFullscreen) {
102
- document.webkitExitFullscreen()
103
- } else if (document.mozCancelFullScreen) {
104
- document.mozCancelFullScreen()
105
- } else if (document.msExitFullscreen) {
106
- document.msExitFullscreen()
107
- }
108
- removeClass(el, 'xgplayer-is-cssfullscreen')
109
- }
110
-
111
- player.getRotateFullscreen = function () {
112
- let player = this
113
- document.documentElement.style.width = '100%'
114
- document.documentElement.style.height = '100%'
115
- if (player.config.fluid) {
116
- player.root.style['padding-top'] = ''
117
- player.root.style['max-width'] = 'unset'
118
- }
119
- if (player.root && !hasClass(player.root, 'xgplayer-rotate-fullscreen')) {
120
- addClass(player.root, 'xgplayer-rotate-fullscreen')
121
- }
122
- player.emit('getRotateFullscreen')
123
- }
124
-
125
- player.exitRotateFullscreen = function () {
126
- let player = this
127
- document.documentElement.style.width = 'unset'
128
- document.documentElement.style.height = 'unset'
129
- if (player.config.fluid) {
130
- player.root.style['width'] = '100%'
131
- player.root.style['height'] = '0'
132
- player.root.style['padding-top'] = `${player.config.height * 100 / player.config.width}%`
133
- player.root.style['max-width'] = '100%'
134
- }
135
- if (player.root && hasClass(player.root, 'xgplayer-rotate-fullscreen')) {
136
- removeClass(player.root, 'xgplayer-rotate-fullscreen')
137
- }
138
- player.emit('exitRotateFullscreen')
139
- }
140
- }
141
-
142
- export default {
143
- name: 'fullscreen',
144
- method: fullscreen
145
- }
@@ -1,214 +0,0 @@
1
- import { on, hasClass, removeClass, addClass } from '../utils/util'
2
- class Keyboard {
3
- constructor (player) {
4
- this.player = player
5
- this.state = {
6
- playbackRate: 0,
7
- isRepeat: false,
8
- keyCode: 0,
9
- repeat: 0,
10
- isBody: false
11
- }
12
- this.timer = null
13
- this.initEvents()
14
- }
15
-
16
- initEvents () {
17
- const {root, config} = this.player
18
- this.player.onBodyKeydown = this.onBodyKeydown.bind(this)
19
- this.player.onKeydown = this.onKeydown.bind(this)
20
- this.player.onKeyup = this.onKeyup.bind(this)
21
- if (!config.keyShortcut || config.keyShortcut === 'on') {
22
- document.addEventListener('keydown', this.player.onBodyKeydown)
23
- root.addEventListener('keydown', this.player.onKeydown)
24
- let destroyFunc = () => {
25
- document.removeEventListener('keydown', this.player.onBodyKeydown)
26
- root.removeEventListener('keydown', this.player.onKeydown)
27
- clearTimeout(this.timer)
28
- this.timer = null
29
- }
30
- on(this.player, 'destroy', destroyFunc)
31
- }
32
- }
33
-
34
- checkTarget (e) {
35
- const {player} = this
36
- return e.target === player.root || e.target === player.video || e.target === player.controls
37
- }
38
-
39
- onBodyKeydown (event) {
40
- let e = event || window.event
41
- const keyCode = e.keyCode
42
- if ((e.target === document.body) && (keyCode === 37 || keyCode === 39 || keyCode === 32)) {
43
- e.preventDefault()
44
- e.cancelBubble = true
45
- e.returnValue = false
46
- if (!e.repeat) {
47
- document.addEventListener('keyup', this.player.onKeyup)
48
- }
49
- this.handler(e)
50
- return false
51
- }
52
- }
53
-
54
- onKeydown (event) {
55
- let e = event || window.event
56
- const keyCode = e.keyCode
57
- if (this.checkTarget(e) && (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40 || keyCode === 32 || keyCode === 27)) {
58
- e.preventDefault()
59
- e.cancelBubble = true
60
- e.returnValue = false
61
- this.player.emit('focus')
62
- if (!e.repeat) {
63
- this.player.root.addEventListener('keyup', this.player.onKeyup)
64
- }
65
- this.handler(e)
66
- return false
67
- }
68
- }
69
-
70
- onKeyup () {
71
- const {state, player} = this
72
- document.removeEventListener('keyup', this.player.onKeyup)
73
- player.root.removeEventListener('keyup', this.player.onKeyup)
74
- if (!state.keyCode) {
75
- return
76
- }
77
- if (state.playbackRate !== 0) {
78
- player.playbackRate = state.playbackRate
79
- }
80
-
81
- if (!state.isRepeat) {
82
- this.handlerKeyCode(state.keyCode, false)
83
- }
84
- state.playbackRate = 0
85
- state.isRepeat = false
86
- state.keyCode = 0
87
- state.repeat = 0
88
- this.changeVolumeSlide()
89
- }
90
-
91
- handler (e) {
92
- const {state, player} = this
93
- state.keyCode = e.keyCode
94
- state.isRepeat = e.repeat
95
- if (e.repeat) {
96
- if (player.config.disableLongPress) {
97
- this.handlerKeyCode(state.keyCode, false)
98
- } else if(state.repeat % 2 === 0) {
99
- this.handlerKeyCode(state.keyCode, true)
100
- }
101
- state.repeat++
102
- }
103
- }
104
-
105
- handlerKeyCode (keyCode, isLonePress) {
106
- const {player, state} = this
107
- switch (keyCode) {
108
- case 39:
109
- // 快进
110
- if (isLonePress) {
111
- state.repeat === 0 && this.changeRate()
112
- } else {
113
- this.seek(false, isLonePress)
114
- }
115
- break
116
- case 37:
117
- // 快退
118
- this.seek(true, isLonePress)
119
- break
120
- case 38:
121
- this.changeVolume(true)
122
- // 上
123
- break
124
- case 40:
125
- this.changeVolume(false)
126
- // 下
127
- break
128
- case 32:
129
- if (!isLonePress) {
130
- player.paused ? player.play() : player.pause()
131
- }
132
- break
133
- case 27:
134
- if (hasClass(player.root, 'xgplayer-is-cssfullscreen')) {
135
- player.exitCssFullscreen()
136
- }
137
- break
138
- default:
139
- //
140
- }
141
- }
142
-
143
- seek (isBack, isLongPress) {
144
- const {player} = this
145
- const keyShortcutStep = player.config.keyShortcutStep || {}
146
- const currentTimeStep = keyShortcutStep.currentTime || 10
147
- if (player.isLoading || player.isSeeking || (isLongPress && this.state.repeat % 8 > 0)) {
148
- return
149
- }
150
- if (isBack) {
151
- if (player.currentTime - currentTimeStep >= 0) {
152
- player.currentTime -= currentTimeStep
153
- } else {
154
- player.currentTime = 0
155
- }
156
- } else {
157
- if(player.maxPlayedTime && player.config.allowSeekPlayed && (player.currentTime + currentTimeStep > player.maxPlayedTime)) {
158
- player.currentTime = player.maxPlayedTime
159
- } else {
160
- if (player.currentTime + currentTimeStep <= player.duration) {
161
- player.currentTime += currentTimeStep
162
- } else {
163
- player.currentTime = player.duration + 1
164
- }
165
- }
166
- }
167
- }
168
-
169
- changeRate () {
170
- this.state.playbackRate = this.player.playbackRate
171
- this.player.playbackRate = this.player.config.keyboardRate || 5
172
- }
173
-
174
- changeVolumeSlide (show) {
175
- const {player} = this
176
- if (!player.controls) {
177
- return
178
- }
179
- if (show) {
180
- player.emit('focus')
181
- if (!hasClass(player.root, 'xgplayer-volume-active')) {
182
- addClass(player.root, 'xgplayer-volume-active')
183
- }
184
- } else {
185
- clearTimeout(this.timer)
186
- this.timer = setTimeout(() => {
187
- removeClass(player.root, 'xgplayer-volume-active')
188
- }, 1000)
189
- }
190
- }
191
-
192
- changeVolume (isup) {
193
- const {player} = this
194
- const keyShortcutStep = player.config.keyShortcutStep || {}
195
- const volumeStep = keyShortcutStep.volume || 0.1
196
- this.changeVolumeSlide(true)
197
- const volume = player.volume
198
- if (isup && volume + volumeStep <= 1) {
199
- player.volume = volume + volumeStep
200
- } else if (!isup && volume - volumeStep >= 0) {
201
- player.volume = volume - volumeStep
202
- }
203
- }
204
- }
205
-
206
- let keyboard = function () {
207
- let player = this
208
- player.keyboard = new Keyboard(player)
209
- }
210
-
211
- export default {
212
- name: 'keyboard',
213
- method: keyboard
214
- }
@@ -1,32 +0,0 @@
1
- import { hasClass } from '../utils/util'
2
-
3
- let localPreview = function () {
4
- let player = this
5
- let root = player.root
6
- function onUpload (upload) {
7
- player.uploadFile = upload.files[0]
8
- let url = URL.createObjectURL(player.uploadFile)
9
- if (hasClass(root, 'xgplayer-nostart')) {
10
- player.config.url = url
11
- player.start()
12
- } else {
13
- player.src = url
14
- let playPromise = player.play()
15
- if (playPromise !== undefined && playPromise) {
16
- playPromise.catch(err => {})
17
- }
18
- }
19
- }
20
- player.on('upload', onUpload)
21
-
22
- function onDestroy () {
23
- player.off('upload', onUpload)
24
- player.off('destroy', onDestroy)
25
- }
26
- player.once('destroy', onDestroy)
27
- }
28
-
29
- export default {
30
- name: 'localPreview',
31
- method: localPreview
32
- }
@@ -1,14 +0,0 @@
1
- let memoryPlay = function () {
2
- let player = this
3
- player.on('memoryPlayStart', (lastPlayTime) => {
4
- setTimeout(() => {
5
- console.log('memoryPlayStart', lastPlayTime, player.readyState, 11)
6
- player.currentTime = lastPlayTime
7
- },)
8
- })
9
- }
10
-
11
- export default {
12
- name: 'memoryPlay',
13
- method: memoryPlay
14
- }
@@ -1,128 +0,0 @@
1
- import { findDom, hasClass, createDom, addClass, removeClass } from '../utils/util'
2
- import Draggabilly from 'draggabilly'
3
-
4
- let miniplayer = function () {
5
- let player = this
6
- let root = player.root
7
- function onMiniplayerBtnClick () {
8
- if (hasClass(root, 'xgplayer-miniplayer-active')) {
9
- player.exitMiniplayer()
10
- } else {
11
- player.getMiniplayer()
12
- }
13
- }
14
- player.on('miniplayerBtnClick', onMiniplayerBtnClick)
15
-
16
- function onDestroy () {
17
- player.off('miniplayerBtnClick', onMiniplayerBtnClick)
18
- player.off('destroy', onDestroy)
19
- }
20
- player.once('destroy', onDestroy)
21
-
22
- player.getMiniplayer = function () {
23
- if (hasClass(root, 'xgplayer-is-fullscreen')) {
24
- this.exitFullscreen(root)
25
- }
26
- if (hasClass(root, 'xgplayer-is-cssfullscreen')) {
27
- this.exitCssFullscreen()
28
- }
29
- if (hasClass(root, 'xgplayer-rotate-fullscreen')) {
30
- this.exitRotateFullscreen()
31
- }
32
- // let ro = this.root.getBoundingClientRect()
33
- // let Top = ro.top
34
- // let Left = ro.left
35
- let dragLay = createDom('xg-miniplayer-lay', '<div></div>', {}, 'xgplayer-miniplayer-lay')
36
- this.root.appendChild(dragLay)
37
- let dragHandle = createDom('xg-miniplayer-drag', `<div class="drag-handle"><span>${this.lang.MINIPLAYER_DRAG}</span></div>`, {tabindex: 9}, 'xgplayer-miniplayer-drag')
38
- this.root.appendChild(dragHandle)
39
- // eslint-disable-next-line no-unused-vars
40
- let draggie = new Draggabilly('.xgplayer', {
41
- handle: '.drag-handle'
42
- })
43
- addClass(this.root, 'xgplayer-miniplayer-active')
44
- this.root.style.right = 0
45
- this.root.style.bottom = '200px'
46
- this.root.style.top = ''
47
- this.root.style.left = ''
48
- this.root.style.width = '320px'
49
- this.root.style.height = '180px'
50
- if (this.config.miniplayerConfig) {
51
- if (this.config.miniplayerConfig.top !== undefined) {
52
- this.root.style.top = this.config.miniplayerConfig.top + 'px'
53
- this.root.style.bottom = ''
54
- }
55
- if (this.config.miniplayerConfig.bottom !== undefined) {
56
- this.root.style.bottom = this.config.miniplayerConfig.bottom + 'px'
57
- }
58
- if (this.config.miniplayerConfig.left !== undefined) {
59
- this.root.style.left = this.config.miniplayerConfig.left + 'px'
60
- this.root.style.right = ''
61
- }
62
- if (this.config.miniplayerConfig.right !== undefined) {
63
- this.root.style.right = this.config.miniplayerConfig.right + 'px'
64
- }
65
- if (this.config.miniplayerConfig.width !== undefined) {
66
- this.root.style.width = this.config.miniplayerConfig.width + 'px'
67
- }
68
- if (this.config.miniplayerConfig.height !== undefined) {
69
- this.root.style.height = this.config.miniplayerConfig.height + 'px'
70
- }
71
- }
72
- if (this.config.fluid) {
73
- this.root.style['padding-top'] = ''
74
- }
75
- let player = this;
76
- ['click', 'touchend'].forEach(item => {
77
- dragLay.addEventListener(item, function (e) {
78
- e.preventDefault()
79
- e.stopPropagation()
80
- player.exitMiniplayer()
81
- // player.root.style.top = `${Top}px`
82
- // player.root.style.left = `${Left}px`
83
- })
84
- })
85
- }
86
-
87
- player.exitMiniplayer = function () {
88
- removeClass(this.root, 'xgplayer-miniplayer-active')
89
- this.root.style.right = ''
90
- this.root.style.bottom = ''
91
- this.root.style.top = ''
92
- this.root.style.left = ''
93
- if (this.config.fluid) {
94
- this.root.style['width'] = '100%'
95
- this.root.style['height'] = '0'
96
- this.root.style['padding-top'] = `${this.config.height * 100 / this.config.width}%`
97
- } else {
98
- if (this.config.width) {
99
- if (typeof this.config.width !== 'number') {
100
- this.root.style.width = this.config.width
101
- } else {
102
- this.root.style.width = `${this.config.width}px`
103
- }
104
- }
105
- if (this.config.height) {
106
- if (typeof this.config.height !== 'number') {
107
- this.root.style.height = this.config.height
108
- } else {
109
- this.root.style.height = `${this.config.height}px`
110
- }
111
- }
112
- }
113
-
114
- let dragLay = findDom(this.root, '.xgplayer-miniplayer-lay')
115
- if (dragLay && dragLay.parentNode) {
116
- dragLay.parentNode.removeChild(dragLay)
117
- }
118
- let dragHandle = findDom(this.root, '.xgplayer-miniplayer-drag')
119
- if (dragHandle && dragHandle.parentNode) {
120
- dragHandle.parentNode.removeChild(dragHandle)
121
- }
122
- }
123
- }
124
-
125
- export default {
126
- name: 'miniplayer',
127
- method: miniplayer
128
- }