-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run prettier on every extension (#813 - part 2)
- Loading branch information
1 parent
17d4f5a
commit 8983d01
Showing
89 changed files
with
32,395 additions
and
30,369 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,114 @@ | ||
(function (Scratch) { | ||
'use strict'; | ||
if (!Scratch.extensions.unsandboxed) { | ||
throw new Error('Recording must be run unsandboxed'); | ||
} | ||
/** @type {MediaRecorder|null} */ | ||
let mediaRecorder = null; | ||
let recordedChunks = []; | ||
const icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjg1MTAzNzAzNDU1IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjMzMjIiIGRhdGEtc3BtLWFuY2hvci1pZD0iYTMxM3guNzc4MTA2OS4wLmkxIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik04MzMgNDQ1LjVjMTcuNjczIDAgMzIgMTQuMzI3IDMyIDMyIDAgMTgzLjcyMi0xNDAuNTUzIDMzNC42MTYtMzE5Ljk5NyAzNTEuMDIxTDU0NS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TI1LjMwNi0zLjMzOC0xNy4xNzUgNy43MzMtMzMuODEgMjQuNzg4LTM3LjQxM2wwLjUxOC0wLjEwNWM1NC4yMDktMTAuNTM3IDg5LjgtNjIuNjA0IDgwLjE3OC0xMTYuNzc0bC0wLjMwNS0xLjY0MmMtMy4zNzItMTcuMzQ4IDcuOTU4LTM0LjE0NiAyNS4zMDYtMzcuNTE4IDE3LjM0OS0zLjM3MiAzNC4xNDYgNy45NTggMzcuNTE4IDI1LjMwNnoiIGZpbGw9IiNmZmZmZmYiIHAtaWQ9IjMzMjMiPjwvcGF0aD48L3N2Zz4='; | ||
class Recording { | ||
getInfo() { | ||
return { | ||
id: 'sipcrecording', | ||
name: 'Recording', | ||
color1: '#696969', | ||
blocks: [ | ||
{ | ||
opcode: 'startRecording', | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: 'Start recording', | ||
blockIconURI: icon, | ||
arguments: {} | ||
}, | ||
{ | ||
opcode: 'stopRecording', | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: 'Stop recording', | ||
blockIconURI: icon, | ||
arguments: {} | ||
}, | ||
{ | ||
opcode: 'stopRecordingAndDownload', | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: 'Stop recording and download with [name] as filename', | ||
blockIconURI: icon, | ||
arguments: { | ||
name: { | ||
type: Scratch.ArgumentType.STRING, | ||
defaultValue: 'recording.wav' | ||
} | ||
} | ||
}, | ||
{ | ||
opcode: 'isRecording', | ||
blockType: Scratch.BlockType.BOOLEAN, | ||
text: 'Recording?', | ||
blockIconURI: icon, | ||
arguments: {} | ||
}, | ||
] | ||
}; | ||
} | ||
async startRecording() { | ||
recordedChunks = []; | ||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { | ||
console.error('The recording function is not supported by the browser'); | ||
return; | ||
} | ||
try { | ||
if (!await Scratch.canRecordAudio()) { | ||
throw new Error('VM denied permission'); | ||
} | ||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | ||
mediaRecorder = new MediaRecorder(stream); | ||
mediaRecorder.addEventListener('dataavailable', function (e) { | ||
recordedChunks.push(e.data); | ||
}); | ||
mediaRecorder.start(); | ||
console.log('Start recording'); | ||
} catch (e) { | ||
console.error('Could not start recording', e); | ||
} | ||
} | ||
stopRecording() { | ||
if (!mediaRecorder) { | ||
console.error('Recording not started'); | ||
return; | ||
} | ||
console.log('Stop recording'); | ||
mediaRecorder.stop(); | ||
mediaRecorder = null; | ||
recordedChunks = []; | ||
} | ||
stopRecordingAndDownload({name}) { | ||
if (!mediaRecorder) { | ||
console.error('Recording not started'); | ||
return; | ||
} | ||
console.log('Stop recording'); | ||
mediaRecorder.addEventListener('stop', function () { | ||
const blob = new Blob(recordedChunks, { type: 'audio/wav' }); | ||
const url = URL.createObjectURL(blob); | ||
const downloadLink = document.createElement('a'); | ||
downloadLink.href = url; | ||
downloadLink.download = name; | ||
document.body.appendChild(downloadLink); | ||
downloadLink.click(); | ||
document.body.removeChild(downloadLink); | ||
URL.revokeObjectURL(url); | ||
recordedChunks = []; | ||
}); | ||
mediaRecorder.stop(); | ||
mediaRecorder = null; | ||
} | ||
isRecording() { | ||
return !!mediaRecorder; | ||
} | ||
} | ||
Scratch.extensions.register(new Recording()); | ||
})(Scratch); | ||
//BY -SIPC- 502415953 | ||
(function (Scratch) { | ||
"use strict"; | ||
if (!Scratch.extensions.unsandboxed) { | ||
throw new Error("Recording must be run unsandboxed"); | ||
} | ||
/** @type {MediaRecorder|null} */ | ||
let mediaRecorder = null; | ||
let recordedChunks = []; | ||
const icon = | ||
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjg1MTAzNzAzNDU1IiBjbGFzcz0iaWNv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AuNzM2LTIyNSAyMjUtMjI1eiBtMCA2NGMtODguMDI5IDAtMTU5LjU1NyA3MC42NDgtMTYwLjk3OCAxNTguMzM4TDM1MiAyOTB2MTg2YzAgODguOTE4IDcyLjA4MiAxNjEgMTYxIDE2MSA4OC4wMjkgMCAxNTkuNTU3LTcwLjY0OCAxNjAuOTc4LTE1OC4zMzhMNjc0IDQ3NlYyOTBjMC04OC45MTgtNzIuMDgyLTE2MS0xNjEtMTYxeiBtMTI0LjU0MyAyNTguNTkxYzE3LjM4OCA4OS40NTMtNDEuMDMyIDE3Ni4wNjQtMTMwLjQ4NSAxOTMuNDUyLTE3LjM0OCAzLjM3Mi0zNC4xNDYtNy45NTgtMzcuNTE4LTI1LjMwNi0zLjMzOC0xNy4xNzUgNy43MzMtMzMuODEgMjQuNzg4LTM3LjQxM2wwLjUxOC0wLjEwNWM1NC4yMDktMTAuNTM3IDg5LjgtNjIuNjA0IDgwLjE3OC0xMTYuNzc0bC0wLjMwNS0xLjY0MmMtMy4zNzItMTcuMzQ4IDcuOTU4LTM0LjE0NiAyNS4zMDYtMzcuNTE4IDE3LjM0OS0zLjM3MiAzNC4xNDYgNy45NTggMzcuNTE4IDI1LjMwNnoiIGZpbGw9IiNmZmZmZmYiIHAtaWQ9IjMzMjMiPjwvcGF0aD48L3N2Zz4="; | ||
class Recording { | ||
getInfo() { | ||
return { | ||
id: "sipcrecording", | ||
name: "Recording", | ||
color1: "#696969", | ||
blocks: [ | ||
{ | ||
opcode: "startRecording", | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: "Start recording", | ||
blockIconURI: icon, | ||
arguments: {}, | ||
}, | ||
{ | ||
opcode: "stopRecording", | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: "Stop recording", | ||
blockIconURI: icon, | ||
arguments: {}, | ||
}, | ||
{ | ||
opcode: "stopRecordingAndDownload", | ||
blockType: Scratch.BlockType.COMMAND, | ||
text: "Stop recording and download with [name] as filename", | ||
blockIconURI: icon, | ||
arguments: { | ||
name: { | ||
type: Scratch.ArgumentType.STRING, | ||
defaultValue: "recording.wav", | ||
}, | ||
}, | ||
}, | ||
{ | ||
opcode: "isRecording", | ||
blockType: Scratch.BlockType.BOOLEAN, | ||
text: "Recording?", | ||
blockIconURI: icon, | ||
arguments: {}, | ||
}, | ||
], | ||
}; | ||
} | ||
async startRecording() { | ||
recordedChunks = []; | ||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { | ||
console.error("The recording function is not supported by the browser"); | ||
return; | ||
} | ||
try { | ||
if (!(await Scratch.canRecordAudio())) { | ||
throw new Error("VM denied permission"); | ||
} | ||
const stream = await navigator.mediaDevices.getUserMedia({ | ||
audio: true, | ||
}); | ||
mediaRecorder = new MediaRecorder(stream); | ||
mediaRecorder.addEventListener("dataavailable", function (e) { | ||
recordedChunks.push(e.data); | ||
}); | ||
mediaRecorder.start(); | ||
console.log("Start recording"); | ||
} catch (e) { | ||
console.error("Could not start recording", e); | ||
} | ||
} | ||
stopRecording() { | ||
if (!mediaRecorder) { | ||
console.error("Recording not started"); | ||
return; | ||
} | ||
console.log("Stop recording"); | ||
mediaRecorder.stop(); | ||
mediaRecorder = null; | ||
recordedChunks = []; | ||
} | ||
stopRecordingAndDownload({ name }) { | ||
if (!mediaRecorder) { | ||
console.error("Recording not started"); | ||
return; | ||
} | ||
console.log("Stop recording"); | ||
mediaRecorder.addEventListener("stop", function () { | ||
const blob = new Blob(recordedChunks, { type: "audio/wav" }); | ||
const url = URL.createObjectURL(blob); | ||
const downloadLink = document.createElement("a"); | ||
downloadLink.href = url; | ||
downloadLink.download = name; | ||
document.body.appendChild(downloadLink); | ||
downloadLink.click(); | ||
document.body.removeChild(downloadLink); | ||
URL.revokeObjectURL(url); | ||
recordedChunks = []; | ||
}); | ||
mediaRecorder.stop(); | ||
mediaRecorder = null; | ||
} | ||
isRecording() { | ||
return !!mediaRecorder; | ||
} | ||
} | ||
Scratch.extensions.register(new Recording()); | ||
})(Scratch); | ||
//BY -SIPC- 502415953 |
Oops, something went wrong.