DraggableAudio
API reference for the DraggableAudio component.
Usage
import React from "react";import { AudioContextProvider } from "components/audio_context";import { DraggableAudio } from "components/draggable_audio";import { upload } from "@canva/asset";export function App() {return (<AudioContextProvider><DraggableAudiotitle="Example audio"durationMs={86047}previewUrl="https://www.canva.dev/example-assets/audio-import/audio.mp3"resolveAudioRef={() => {return upload({type: "AUDIO",title: "Example audio",mimeType: "audio/mp3",durationMs: 86047,url: "https://www.canva.dev/example-assets/audio-import/audio.mp3",});}}/></AudioContextProvider>);}
tsx
Props
Required
A human-readable title that appears in the Canva editor.
Required
The URL of the audio file.
Required
The URL of the audio file to play when the user clicks the Play button.
Required
The duration of the audio file, in milliseconds.