0.3.0 • Published 14 days ago

capacitor-play-audio-from-url v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

capacitor-play-audio-from-url

This capacitor plugin enables playing audio natively from a remote url, on web, android and ios.

Usage

import { PlayAudioFromUrl } from 'capacitor-play-audio-from-url'

PlayAudioFromUrl
    .play({ url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3' })
    .then(() => console.log('Audio played'))
    .catch((error) => console.error('Error playing audio (e.g. failed to load)', error));
// or
try {
    await PlayAudioFromUrl.play({url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'})
    console.log('Audio played')
}catch (error) {
    console.error('Error playing audio (e.g. failed to load)', error)
}

Install

npm install capacitor-play-audio-from-url
npx cap sync

API

play(...)

play(options: PlayOptions) => Promise<void>

Plays an audio file from a given URL. In web mode, to avoid getting audio play rejected by mobile browsers when playing many audios, the audio sources are cached in an LRU cache with 256 entries.

ParamTypeDescription
optionsPlayOptions- The options for playing the audio. Must include a url property with the URL of the audio file.

Interfaces

PlayOptions

PropType
urlstring

Development

To test, it is best to link it to a project using

npm install <path-to-the-project>

Then lots of npx cap sync, npx cap copy and building the apps for good measure.:)

0.3.0

14 days ago

0.1.2

14 days ago

0.2.0

14 days ago

0.1.1

19 days ago

0.1.0

19 days ago

0.0.5

19 days ago

0.0.4

19 days ago

0.0.3

19 days ago

0.0.2

19 days ago

0.0.1

19 days ago