Skip to content

Instantly share code, notes, and snippets.

@dongido001
Created May 12, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongido001/1e9d34296ec3b72ffc8e2f35214f6c45 to your computer and use it in GitHub Desktop.
Save dongido001/1e9d34296ec3b72ffc8e2f35214f6c45 to your computer and use it in GitHub Desktop.
// [...]
recording.addEventListener("pointerup", async () => {
// Stop the recording
recorder.state == "recording" && recorder.stop()
recordedChunks = await recordedChunks
recordedBlob = new Blob(recordedChunks, {type: 'audio/ogg; codecs="opus"'});
// Create an audio file
var audioFile = new File([recordedBlob], "audio.ogg", {
type: 'audio/ogg; codecs="opus"',
});
// Send the recorded file to Stream CDN
response = await channel.sendFile(
audioFile,
'audio.ogg',
)
const attachments = [{
type: 'file',
thumb_url: response.file,
asset_url: response.file,
}]
// Send the attachment to the channel
sendMessage("", attachments)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment