cm-chessboard 5.5.17 → 5.5.18
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.
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
<p>Works best in Chrome with webm format.</p>
|
|
14
14
|
<div class="board board-small" id="board"></div>
|
|
15
15
|
<video id="videoOut" controls="controls"></video>
|
|
16
|
+
<br/>
|
|
17
|
+
<a href="" style="visibility: hidden" id="download-link">Download video</a>
|
|
16
18
|
<script type="module">
|
|
17
19
|
import {RenderVideo} from "../../src/cm-chessboard/extensions/render-video/RenderVideo.js"
|
|
18
20
|
import {Chessboard} from "../../src/cm-chessboard/Chessboard.js"
|
|
@@ -38,6 +40,8 @@
|
|
|
38
40
|
chessboard.recorderStop().then((url) => {
|
|
39
41
|
const video = document.getElementById("videoOut")
|
|
40
42
|
video.src = url
|
|
43
|
+
document.getElementById("download-link").href = url
|
|
44
|
+
document.getElementById("download-link").style.visibility = "visible"
|
|
41
45
|
})
|
|
42
46
|
|
|
43
47
|
</script>
|
package/package.json
CHANGED
|
@@ -11,17 +11,20 @@ export class RenderVideo extends Extension {
|
|
|
11
11
|
constructor(chessboard, props) {
|
|
12
12
|
super(chessboard, props)
|
|
13
13
|
this.props = {
|
|
14
|
-
mediaType: "auto"
|
|
14
|
+
mediaType: "auto",
|
|
15
|
+
safariMode: true
|
|
15
16
|
}
|
|
16
17
|
Object.assign(this.props, props)
|
|
17
18
|
if(this.props.mediaType === "auto") {
|
|
18
|
-
if(MediaRecorder.isTypeSupported("video/mp4")) {
|
|
19
|
-
this.props.mediaType = "video/mp4"
|
|
20
|
-
} else if(MediaRecorder.isTypeSupported("video/webm;codecs=
|
|
19
|
+
if(MediaRecorder.isTypeSupported("video/mp4;codecs:h264,aac")) {
|
|
20
|
+
this.props.mediaType = "video/mp4;codecs:h264,aac"
|
|
21
|
+
} else if(MediaRecorder.isTypeSupported("video/webm;codecs=h264")) {
|
|
21
22
|
this.props.mediaType = "video/webm;codecs=H264"
|
|
22
23
|
} else if(MediaRecorder.isTypeSupported("video/webm")) {
|
|
23
24
|
this.props.mediaType = "video/webm"
|
|
24
|
-
} else {
|
|
25
|
+
} else if(MediaRecorder.isTypeSupported("video/mp4")) {
|
|
26
|
+
this.props.mediaType = "video/mp4"
|
|
27
|
+
}else {
|
|
25
28
|
console.error("no suitable mediaType found")
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -118,7 +121,7 @@ export class RenderVideo extends Extension {
|
|
|
118
121
|
const blob = new Blob([serialized], {type: "image/svg+xml"})
|
|
119
122
|
const blobURL = URL.createObjectURL(blob)
|
|
120
123
|
// strange Safari "bug" that the content has only 300x150px
|
|
121
|
-
const image = this.props.
|
|
124
|
+
const image = this.props.safariMode ? this.image : new Image()
|
|
122
125
|
image.onload = () => {
|
|
123
126
|
this.context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height, 0, 0, this.canvas.width, this.canvas.height)
|
|
124
127
|
resolve()
|