Skip to content

Commit f170866

Browse files
authored
feat: enable camera for video extenstion and microphone for recording (#1493)
Noticed that the video extension and the sound recording need an attribute adding on the scratch iframe. Without this you get violations in the console for the camera - or the microphone can not connect <img width="953" height="567" alt="camera-violation" src="https://github.com/user-attachments/assets/a9fd5dab-ae92-4b42-a985-efc0a91b019a" /> <img width="1475" height="761" alt="microphone-not-work" src="https://github.com/user-attachments/assets/5dabb389-3b2f-4535-b94f-23b59c41fc4b" /> Simple fix here should get it working, so the user should be accessed for permission to connect liek in the following images. <img width="1317" height="973" alt="video-set-up" src="https://github.com/user-attachments/assets/07d51ac9-522b-4f5a-bac4-fcb3bf483948" /> <img width="1151" height="893" alt="microphone-set-up" src="https://github.com/user-attachments/assets/e5448223-d945-4093-97ba-7af93449405e" />
1 parent d763f69 commit f170866

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/components/Editor/Project/ScratchContainer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export default function ScratchContainer() {
124124
className="scratch-container__iframe"
125125
src={iframeSrcUrl}
126126
title={"Scratch"}
127+
allow="camera; microphone"
127128
style={{
128129
width: "100%",
129130
minWidth: `${SCRATCH_MIN_WIDTH}px`,

src/components/Editor/Project/ScratchContainer.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ describe("ScratchContainer", () => {
137137
);
138138
expect(viewport).toHaveClass("scratch-container__viewport");
139139
expect(iframe).toBeInTheDocument();
140+
const allow = iframe.getAttribute("allow") ?? "";
141+
expect(allow).toEqual(expect.stringContaining("camera"));
142+
expect(allow).toEqual(expect.stringContaining("microphone"));
140143
expect(iframe).toHaveStyle({
141144
minWidth: "1024px",
142145
});

0 commit comments

Comments
 (0)