@cliff-studio/sanity-plugin-bunny-input 1.0.4 → 1.0.6
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
|
@@ -27,7 +27,6 @@ export function BunnyInput(props) {
|
|
|
27
27
|
pollIntervalRef.current = window.setInterval(async () => {
|
|
28
28
|
try {
|
|
29
29
|
const videoData = await getVideo(config, value.videoId)
|
|
30
|
-
console.log('[bunny] getVideo response', JSON.stringify(videoData, null, 2))
|
|
31
30
|
const status = mapBunnyStatus(videoData.status)
|
|
32
31
|
|
|
33
32
|
if (status === 'ready' || status === 'error') {
|
|
@@ -37,13 +36,20 @@ export function BunnyInput(props) {
|
|
|
37
36
|
pollIntervalRef.current = null
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
const width = Number(videoData.width)
|
|
40
|
+
const height = Number(videoData.height)
|
|
41
|
+
|
|
42
|
+
const hasDims = Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0
|
|
43
|
+
const ratio = hasDims ? Number((width / height).toFixed(6)) : null
|
|
44
|
+
|
|
40
45
|
onChange(
|
|
41
46
|
set({
|
|
42
47
|
...value,
|
|
43
48
|
status,
|
|
44
49
|
duration: videoData.length,
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
height: hasDims ? height : null,
|
|
51
|
+
width: hasDims ? width : null,
|
|
52
|
+
ratio: ratio,
|
|
47
53
|
thumbnailUrl: getThumbnailUrl(config.cdnHostname, value.videoId),
|
|
48
54
|
playbackUrl: getPlaybackUrl(config.cdnHostname, value.videoId),
|
|
49
55
|
mp4Url: getMp4Url(config.cdnHostname, value.videoId),
|
package/src/schema.js
CHANGED
|
@@ -54,13 +54,19 @@ export const createBunnyVideoSchema = (config) => {
|
|
|
54
54
|
defineField({
|
|
55
55
|
type: 'number',
|
|
56
56
|
title: 'Video width',
|
|
57
|
-
name: '
|
|
57
|
+
name: 'width',
|
|
58
58
|
readOnly: true,
|
|
59
59
|
}),
|
|
60
60
|
defineField({
|
|
61
61
|
type: 'number',
|
|
62
62
|
title: 'Video height',
|
|
63
|
-
name: '
|
|
63
|
+
name: 'height',
|
|
64
|
+
readOnly: true,
|
|
65
|
+
}),
|
|
66
|
+
defineField({
|
|
67
|
+
type: 'string',
|
|
68
|
+
title: 'Video ratio',
|
|
69
|
+
name: 'ratio',
|
|
64
70
|
readOnly: true,
|
|
65
71
|
}),
|
|
66
72
|
defineField({
|