html2app • JS Bridge
    Preparing search index...

    Variable MicrophoneConst

    Microphone: {
        start(): Promise<MessageResponse<{}>>;
        stop(): Promise<MessageResponse<{ file: PickedFile }>>;
        cancel(): Promise<MessageResponse<{}>>;
    } = ...

    Microphone plugin for recording audio on the device.

    Type Declaration

    Android only for now. Requires the microphone plugin to be enabled in the app configuration.

    • Recordings are AAC audio in an .m4a file.
    • Microphone.stop returns a PickedFile with a localhost URL. Play it with <audio src="...">.
    • Only one recording can run at a time.
    • The first Microphone.start asks the user for the microphone permission.
    • Recordings are stored in the app cache. They are deleted when the local server starts or closes, so save a recording with FileSaver.saveUrl if you need to keep it.
    import { Microphone } from '@yandeu/js-bridge/lib/plugins/microphone.js'

    await Microphone.start()
    // ... later
    const res = await Microphone.stop()
    if (res.ok) audio.src = res.payload.file.url