Skip to content

Commit 033a6fa

Browse files
author
longgui0318
committed
Video preview supports sound
1 parent 56392a8 commit 033a6fa

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "wavespeed-comfyui"
33
description = "This is a custom node for ComfyUI that allows you to use the WaveSpeed AI API directly in ComfyUI. WaveSpeed AI is a high-performance AI image and video generation service platform offering industry-leading generation speeds. For more information, see [a/WaveSpeed AI Documentation](https://wavespeed.ai/docs)."
4-
version = "1.3.7"
4+
version = "1.3.8"
55
license = {file = "LICENSE"}
66
dependencies = ["requests", "pillow"]
77

web/previewVideo.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,20 @@ export function addVideoPreview(nodeType, options = {}) {
5151
return new Promise((cb) => {
5252
const videoEl = document.createElement('video');
5353
videoEl.addEventListener('loadedmetadata', () => {
54-
videoEl.controls = false;
54+
// Show native controls so user can unmute if desired
55+
videoEl.controls = true;
5556
videoEl.loop = true;
57+
// Start muted to satisfy autoplay policies; allow user to unmute via click/controls
5658
videoEl.muted = true;
59+
// iOS/Safari inline playback with sound after gesture
60+
videoEl.playsInline = true;
61+
// Click to unmute and continue playback with audio
62+
videoEl.addEventListener('click', () => {
63+
if (videoEl.muted) {
64+
videoEl.muted = false;
65+
videoEl.play();
66+
}
67+
});
5768
resizeVideoAspectRatio(videoEl, BASE_SIZE, BASE_SIZE);
5869
cb(videoEl);
5970
});
@@ -124,9 +135,14 @@ export function addVideoPreview(nodeType, options = {}) {
124135

125136
this.imgs.forEach((img) => {
126137
if (img instanceof HTMLVideoElement) {
138+
// Keep initial autoplay muted; user can unmute via controls or click
127139
img.muted = true;
128140
img.autoplay = true;
129-
img.play();
141+
// Best-effort autoplay; ignore promise rejection from blocked autoplay with sound
142+
const playPromise = img.play();
143+
if (playPromise && typeof playPromise.catch === 'function') {
144+
playPromise.catch(() => {});
145+
}
130146
}
131147
});
132148

0 commit comments

Comments
 (0)