xgplayer 2.31.7 → 2.31.8
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/errorRetry.js +1 -1
- package/browser/controls/nativeTextTrack.js +1 -1
- package/browser/controls/screenShot.js +1 -1
- package/browser/core_player.js +1 -1
- package/browser/core_player.js.map +1 -1
- package/browser/index.js +2 -2
- package/browser/index.js.map +1 -1
- package/browser/simple_player.js +1 -1
- package/browser/simple_player.js.map +1 -1
- package/dist/controls/errorRetry.js +1 -1
- package/dist/controls/nativeTextTrack.js +1 -1
- package/dist/controls/screenShot.js +1 -1
- package/dist/core_player.js +1 -1
- package/dist/core_player.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/simple_player.js +1 -1
- package/dist/simple_player.js.map +1 -1
- package/es/controls/errorRetry.js +1 -1
- package/es/controls/nativeTextTrack.js +1 -1
- package/es/controls/screenShot.js +1 -1
- package/es/core_player.js +1 -1
- package/es/core_player.js.map +1 -1
- package/es/index.js +2 -2
- 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 -2
- package/src/controls/screenShot.js +13 -4
- package/version.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xgplayer",
|
|
3
|
-
"version": "2.31.
|
|
3
|
+
"version": "2.31.8",
|
|
4
4
|
"description": "video player",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"release:stable": "npm version patch && npm publish --registry=https://registry.npmjs.org",
|
|
16
16
|
"release:alpha": "npm version prerelease --preid=alpha && npm publish --tag xgplayer-2-alpha --registry=https://registry.npmjs.org",
|
|
17
17
|
"release:alpha-test": "npm publish --tag alpha-test-2x --registry=https://registry.npmjs.org"
|
|
18
|
-
|
|
19
18
|
},
|
|
20
19
|
"keywords": [
|
|
21
20
|
"video",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
let screenShot = function () {
|
|
2
2
|
let player = this
|
|
3
3
|
let screenShotOptions = player.config.screenShot
|
|
4
|
+
let callBack = null
|
|
4
5
|
if (!screenShotOptions) {
|
|
5
6
|
return
|
|
6
7
|
}
|
|
@@ -8,7 +9,8 @@ let screenShot = function () {
|
|
|
8
9
|
player.video.setAttribute('crossOrigin', 'anonymous')
|
|
9
10
|
|
|
10
11
|
let encoderOptions = 0.92
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
if (screenShotOptions.quality || screenShotOptions.quality === 0) {
|
|
12
14
|
encoderOptions = screenShotOptions.quality
|
|
13
15
|
}
|
|
14
16
|
let type = screenShotOptions.type === undefined ? 'image/png' : screenShotOptions.type
|
|
@@ -17,9 +19,9 @@ let screenShot = function () {
|
|
|
17
19
|
let canvas = document.createElement('canvas')
|
|
18
20
|
let canvasCtx = canvas.getContext('2d')
|
|
19
21
|
let img = new Image()
|
|
20
|
-
canvas.width = this.config.width || 600
|
|
21
|
-
canvas.height = this.config.height || 337.5
|
|
22
22
|
|
|
23
|
+
canvas.width = this.config.width || 600
|
|
24
|
+
canvas.height = this.config.height || 337.5
|
|
23
25
|
let saveScreenShot = function (data, filename) {
|
|
24
26
|
let saveLink = document.createElement('a')
|
|
25
27
|
saveLink.href = data
|
|
@@ -33,12 +35,19 @@ let screenShot = function () {
|
|
|
33
35
|
save = screenShotOptions.saveImg === undefined ? save : screenShotOptions.saveImg
|
|
34
36
|
canvas.width = player.video.videoWidth || 600
|
|
35
37
|
canvas.height = player.video.videoHeight || 337.5
|
|
38
|
+
callBack = screenShotOptions.callBack
|
|
36
39
|
img.onload = (function () {
|
|
37
40
|
canvasCtx.drawImage(player.video, 0, 0, canvas.width, canvas.height)
|
|
38
41
|
img.src = canvas.toDataURL(type, encoderOptions).replace(type, 'image/octet-stream')
|
|
39
42
|
let screenShotImg = img.src.replace(/^data:image\/[^;]+/, 'data:application/octet-stream')
|
|
43
|
+
let saveFileName = screenShotOptions.fileName || player.lang.SCREENSHOT
|
|
44
|
+
|
|
40
45
|
player.emit('screenShot', screenShotImg)
|
|
41
|
-
save &&
|
|
46
|
+
if (save && callBack) {
|
|
47
|
+
callBack(screenShotImg, saveFileName, format)
|
|
48
|
+
} else {
|
|
49
|
+
save && saveScreenShot(screenShotImg, saveFileName + format)
|
|
50
|
+
}
|
|
42
51
|
})()
|
|
43
52
|
}
|
|
44
53
|
player.on('screenShotBtnClick', player.screenShot)
|
package/version.json
CHANGED