cm-chessboard 5.5.2 → 5.5.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.
package/package.json
CHANGED
|
@@ -17,20 +17,26 @@ export class RenderVideo extends Extension {
|
|
|
17
17
|
this.images = []
|
|
18
18
|
this.makeSpriteInline()
|
|
19
19
|
this.registerExtensionPoint(EXTENSION_POINT.animation, () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
if(this.recorder && this.recorder.state === "recording") {
|
|
21
|
+
let clonedSvgElement = this.chessboard.view.svg.cloneNode(true)
|
|
22
|
+
let serialized = new XMLSerializer().serializeToString(clonedSvgElement)
|
|
23
|
+
const blob = new Blob([serialized], {type: "image/svg+xml"})
|
|
24
|
+
const blobURL = URL.createObjectURL(blob)
|
|
25
|
+
const image = new Image()
|
|
26
|
+
this.images.push(image)
|
|
27
|
+
image.onload = () => {
|
|
28
|
+
let context = this.canvas.getContext('2d')
|
|
29
|
+
context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
|
|
30
|
+
this.recorder.requestData()
|
|
31
|
+
}
|
|
32
|
+
image.src = blobURL
|
|
30
33
|
}
|
|
31
|
-
image.src = blobURL
|
|
32
34
|
})
|
|
33
35
|
this.registerMethod("recorderStart", () => {
|
|
36
|
+
if(this.recorder && this.recorder.state === "recording") {
|
|
37
|
+
console.error("recorder is running")
|
|
38
|
+
return
|
|
39
|
+
}
|
|
34
40
|
let all = document.querySelectorAll("svg *")
|
|
35
41
|
for (let i = 0; i < all.length; i++) {
|
|
36
42
|
this.transferComputedStyle(all[i])
|
|
@@ -57,6 +63,10 @@ export class RenderVideo extends Extension {
|
|
|
57
63
|
* returns the url of the recorded media
|
|
58
64
|
*/
|
|
59
65
|
this.registerMethod("recorderStop", () => {
|
|
66
|
+
if(!this.recorder || this.recorder.state !== "recording") {
|
|
67
|
+
console.error("recorder is not recording")
|
|
68
|
+
return
|
|
69
|
+
}
|
|
60
70
|
this.recorder.stop()
|
|
61
71
|
console.log("recorder", this.recorder.state)
|
|
62
72
|
return URL.createObjectURL(new Blob(this.recordedData, {type: this.props.mediaType}))
|