xgplayer 2.30.2-alpha.3 → 2.31.2
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.
- package/browser/controls.js.map +1 -0
- package/browser/core_player.js +1 -1
- package/browser/core_player.js.map +1 -1
- package/browser/index.js +3 -3
- package/browser/index.js.map +1 -1
- package/browser/player.js.map +1 -0
- package/browser/simple_player.js +1 -1
- package/browser/simple_player.js.map +1 -1
- package/dist/controls.js.map +1 -0
- package/dist/core_player.js +1 -1
- package/dist/core_player.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/player.js.map +1 -0
- package/dist/simple_player.js +1 -1
- package/dist/simple_player.js.map +1 -1
- package/es/controls/danmu.js +1 -1
- package/es/controls/errorRetry.js +1 -1
- package/es/controls/fullscreen.js +1 -1
- package/es/controls/nativeTextTrack.js +1 -1
- package/es/controls/pip.js +1 -1
- package/es/controls/play.js +1 -1
- package/es/controls/playbackRate.js +1 -1
- package/es/controls/volume.js +1 -1
- package/es/core_player.js +1 -1
- package/es/core_player.js.map +1 -1
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/simple_player.js +1 -1
- package/es/simple_player.js.map +1 -1
- package/package.json +1 -1
- package/src/controls/fullscreen.js +23 -7
- package/src/controls/pip.js +25 -5
- package/src/controls/play.js +5 -0
- package/src/controls/volume.js +4 -1
- package/src/player.js +1 -1
- package/src/proxy.js +1 -1
- package/src/skin/controls/playbackRate.js +5 -1
- package/src/utils/util.js +11 -0
- package/version.json +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { hasClass, addClass, removeClass } from '../utils/util'
|
|
1
|
+
import { hasClass, addClass, removeClass, PresentationMode, checkWebkitSetPresentationMode } from '../utils/util'
|
|
2
2
|
|
|
3
3
|
let fullscreen = function () {
|
|
4
4
|
let player = this
|
|
5
5
|
let root = player.root
|
|
6
6
|
|
|
7
7
|
function onFullscreenBtnClick () {
|
|
8
|
-
if(player.config.rotateFullscreen) {
|
|
9
|
-
if(hasClass(root, 'xgplayer-rotate-fullscreen')) {
|
|
8
|
+
if (player.config.rotateFullscreen) {
|
|
9
|
+
if (hasClass(root, 'xgplayer-rotate-fullscreen')) {
|
|
10
10
|
player.exitRotateFullscreen()
|
|
11
11
|
} else {
|
|
12
12
|
player.getRotateFullscreen()
|
|
@@ -30,7 +30,7 @@ let fullscreen = function () {
|
|
|
30
30
|
removeClass(root, 'xgplayer-is-fullscreen')
|
|
31
31
|
player.emit('exitFullscreen')
|
|
32
32
|
}
|
|
33
|
-
if(player.danmu && typeof player.danmu.resize === 'function') {
|
|
33
|
+
if (player.danmu && typeof player.danmu.resize === 'function') {
|
|
34
34
|
player.danmu.resize()
|
|
35
35
|
}
|
|
36
36
|
};
|
|
@@ -38,21 +38,37 @@ let fullscreen = function () {
|
|
|
38
38
|
document.addEventListener(item, onFullscreenChange)
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
player.video.addEventListener(
|
|
41
|
+
player.video.addEventListener('webkitbeginfullscreen', function () {
|
|
42
42
|
addClass(root, 'xgplayer-is-fullscreen')
|
|
43
43
|
player.emit('requestFullscreen')
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
-
player.video.addEventListener(
|
|
46
|
+
player.video.addEventListener('webkitendfullscreen', function () {
|
|
47
47
|
removeClass(root, 'xgplayer-is-fullscreen')
|
|
48
48
|
player.emit('exitFullscreen')
|
|
49
49
|
})
|
|
50
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
|
+
|
|
51
63
|
function onDestroy () {
|
|
52
64
|
player.off('fullscreenBtnClick', onFullscreenBtnClick);
|
|
53
65
|
['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'].forEach(item => {
|
|
54
66
|
document.removeEventListener(item, onFullscreenChange)
|
|
55
67
|
})
|
|
68
|
+
|
|
69
|
+
checkWebkitSetPresentationMode(player.video) &&
|
|
70
|
+
player.video.removeEventListener('webkitpresentationmodechanged', onWebkitpresentationmodechanged)
|
|
71
|
+
|
|
56
72
|
player.off('destroy', onDestroy)
|
|
57
73
|
}
|
|
58
74
|
player.once('destroy', onDestroy)
|
|
@@ -126,4 +142,4 @@ let fullscreen = function () {
|
|
|
126
142
|
export default {
|
|
127
143
|
name: 'fullscreen',
|
|
128
144
|
method: fullscreen
|
|
129
|
-
}
|
|
145
|
+
}
|
package/src/controls/pip.js
CHANGED
|
@@ -1,25 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { PresentationMode, checkWebkitSetPresentationMode } from '../utils/util'
|
|
3
|
+
|
|
1
4
|
let pip = function () {
|
|
2
5
|
let player = this
|
|
3
6
|
function onPipBtnClick () {
|
|
4
7
|
if (player.video !== document.pictureInPictureElement) {
|
|
5
|
-
player.video.requestPictureInPicture()
|
|
8
|
+
player.video.requestPictureInPicture()
|
|
6
9
|
} else {
|
|
7
|
-
document.exitPictureInPicture()
|
|
10
|
+
document.exitPictureInPicture()
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
player.on('pipBtnClick', onPipBtnClick)
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
const onWebkitpresentationmodechanged = (e) => {
|
|
16
|
+
const mode = player.video.webkitPresentationMode
|
|
17
|
+
this.pMode = mode
|
|
18
|
+
if (mode === PresentationMode.PIP) {
|
|
19
|
+
// 进入pip模式
|
|
20
|
+
player.emit('requestPictureInPicture', e.pictureInPictureWindow)
|
|
21
|
+
} else if (mode === PresentationMode.INLINE) {
|
|
22
|
+
// 退出pip,进去inline模式
|
|
23
|
+
player.emit('exitPictureInPicture')
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
player.video.addEventListener('enterpictureinpicture', function (pipWindow) {
|
|
13
28
|
player.emit('requestPictureInPicture', pipWindow)
|
|
14
29
|
})
|
|
15
30
|
|
|
16
|
-
player.video.addEventListener(
|
|
31
|
+
player.video.addEventListener('leavepictureinpicture', function () {
|
|
17
32
|
player.emit('exitPictureInPicture')
|
|
18
33
|
})
|
|
19
34
|
|
|
35
|
+
checkWebkitSetPresentationMode(player.video) &&
|
|
36
|
+
player.video.addEventListener('webkitpresentationmodechanged', onWebkitpresentationmodechanged)
|
|
37
|
+
|
|
20
38
|
function onDestroy () {
|
|
21
39
|
player.off('pipBtnClick', onPipBtnClick)
|
|
22
40
|
player.off('destroy', onDestroy)
|
|
41
|
+
checkWebkitSetPresentationMode(player.video) &&
|
|
42
|
+
player.video.removeEventListener('webkitpresentationmodechanged', onWebkitpresentationmodechanged)
|
|
23
43
|
}
|
|
24
44
|
player.once('destroy', onDestroy)
|
|
25
45
|
}
|
|
@@ -27,4 +47,4 @@ let pip = function () {
|
|
|
27
47
|
export default {
|
|
28
48
|
name: 'pip',
|
|
29
49
|
method: pip
|
|
30
|
-
}
|
|
50
|
+
}
|
package/src/controls/play.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasClass } from '../utils/util'
|
|
2
|
+
|
|
1
3
|
let play = function () {
|
|
2
4
|
let player = this
|
|
3
5
|
|
|
@@ -5,6 +7,9 @@ let play = function () {
|
|
|
5
7
|
if (!player.config.allowPlayAfterEnded && player.ended) {
|
|
6
8
|
return
|
|
7
9
|
}
|
|
10
|
+
if(hasClass(player.root, 'xgplayer-nostart')) {
|
|
11
|
+
player.start()
|
|
12
|
+
}
|
|
8
13
|
if (player.paused) {
|
|
9
14
|
let playPromise = player.play()
|
|
10
15
|
if (playPromise !== undefined && playPromise) {
|
package/src/controls/volume.js
CHANGED
|
@@ -15,6 +15,9 @@ let volume = function () {
|
|
|
15
15
|
bar = container.querySelector('.xgplayer-bar')
|
|
16
16
|
selected = container.querySelector('.xgplayer-drag')
|
|
17
17
|
if (sniffer.device === 'mobile') {
|
|
18
|
+
if(player.volume === 0) {
|
|
19
|
+
player.video.muted = true
|
|
20
|
+
}
|
|
18
21
|
onVolumeChange()
|
|
19
22
|
}
|
|
20
23
|
}
|
|
@@ -138,7 +141,7 @@ let volume = function () {
|
|
|
138
141
|
removeClass(root, 'xgplayer-volume-muted')
|
|
139
142
|
removeClass(root, 'xgplayer-volume-small')
|
|
140
143
|
removeClass(root, 'xgplayer-volume-large')
|
|
141
|
-
if (player.volume === 0) {
|
|
144
|
+
if (player.volume === 0 || player.muted) {
|
|
142
145
|
addClass(root, 'xgplayer-volume-muted')
|
|
143
146
|
} else if (player.volume < 0.5) {
|
|
144
147
|
addClass(root, 'xgplayer-volume-small')
|
package/src/player.js
CHANGED
|
@@ -56,7 +56,7 @@ class Player extends Proxy {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
// this.rootBackup = copyDom(this.root)
|
|
59
|
-
addClass(this.root, `xgplayer xgplayer-${sniffer.device} xgplayer-nostart ${this.config.controls ? '' : 'xgplayer-no-controls'}`)
|
|
59
|
+
addClass(this.root, `xgplayer xgplayer-${sniffer.device} xgplayer-nostart xgplayer-pause ${this.config.controls ? '' : 'xgplayer-no-controls'}`)
|
|
60
60
|
this.root.appendChild(this.controls)
|
|
61
61
|
if (this.config.fluid) {
|
|
62
62
|
this.root.style['max-width'] = '100%'
|
package/src/proxy.js
CHANGED
|
@@ -87,7 +87,7 @@ class Proxy {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
this.ev = ['play', 'playing', 'pause', 'ended', 'error', 'seeking', 'seeked', 'progress',
|
|
90
|
-
'timeupdate', 'waiting', 'canplay', 'canplaythrough', 'durationchange', 'volumechange', 'loadedmetadata', 'loadeddata', 'loadstart'
|
|
90
|
+
'timeupdate', 'waiting', 'canplay', 'canplaythrough', 'durationchange', 'volumechange', 'ratechange', 'loadedmetadata', 'loadeddata', 'loadstart'
|
|
91
91
|
].map((item) => {
|
|
92
92
|
return {
|
|
93
93
|
[item]: `on${item.charAt(0).toUpperCase()}${item.slice(1)}`
|
|
@@ -124,11 +124,15 @@ let s_playbackRate = function () {
|
|
|
124
124
|
player.switchPlaybackRate = function (playbackRateObj = {}) {
|
|
125
125
|
let liList = player.controls.querySelectorAll('.xgplayer-playbackrate ul li')
|
|
126
126
|
for(let i = 0; i < liList.length; i++) {
|
|
127
|
-
if(liList[i].getAttribute('cname') === `${playbackRateObj.playbackRate}` || i === playbackRateObj.index) {
|
|
127
|
+
if(!hasClass(liList[i], 'selected') && (liList[i].getAttribute('cname') === `${playbackRateObj.playbackRate}` || i === playbackRateObj.index)) {
|
|
128
128
|
liList[i].click()
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
player.on('ratechange', () => {
|
|
134
|
+
player.switchPlaybackRate({ playbackRate: player.playbackRate })
|
|
135
|
+
})
|
|
132
136
|
}
|
|
133
137
|
|
|
134
138
|
export default {
|
package/src/utils/util.js
CHANGED
|
@@ -340,8 +340,19 @@ export function setStyle(elem, name, value) {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
export const PresentationMode = {
|
|
344
|
+
PIP: 'picture-in-picture',
|
|
345
|
+
INLINE: 'inline',
|
|
346
|
+
FULLSCREEN: 'fullscreen'
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function checkWebkitSetPresentationMode (video) {
|
|
350
|
+
return typeof video.webkitSetPresentationMode === 'function'
|
|
351
|
+
}
|
|
352
|
+
|
|
343
353
|
export const util = {
|
|
344
354
|
createDom, hasClass, addClass, removeClass, toggleClass, findDom, padStart, format, event, typeOf,
|
|
345
355
|
deepCopy, getBgImage, copyDom, setInterval: _setInterval, clearInterval: _clearInterval, createImgBtn, isWeiXin, isUc, computeWatchDur,
|
|
346
356
|
offInDestroy, on, once, getBuffered2, checkIsBrowser, setStyle
|
|
347
357
|
}
|
|
358
|
+
|
package/version.json
CHANGED