ionic-audio-plugin
v0.1.1
Published
Audio playback
Downloads
21
Readme
ionic-audio
Audio playback
Install
npm install ionic-audio-plugin
npx cap syncSetup
For native/remote control of you media playback to work, your @UIApplicationMain needs to implement UIResponder and send a notification when a remote control event is received.
import UIKit
import Capacitor
import IonicAudioPlugin
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
override func remoteControlReceived(with event: UIEvent?) {
NotificationCenter.default.post(name: .remoteControlReceived, object: event)
}
}API
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
play(...)
play(options: PlayOptions) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------- |
| options | PlayOptions |
resume()
resume() => Promise<void>pause()
pause() => Promise<void>stop()
stop() => Promise<void>seekTo(...)
seekTo(options: SeekToOptions) => Promise<void>| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | SeekToOptions |
status(...)
status(callback: AudioStatusCallback) => void| Param | Type |
| -------------- | ------------------------------------------------------------------- |
| callback | AudioStatusCallback |
Interfaces
PlayOptions
| Prop | Type |
| ------------- | ------------------- |
| url | string |
| title | string |
| album | string |
| artwork | string |
SeekToOptions
| Prop | Type |
| ------------- | ------------------- |
| seconds | number |
AudioStatus
| Prop | Type |
| ----------------- | ----------------------------------------------- |
| state | 'playing' | 'paused' | 'stopped' |
| url | string |
| duration | number |
| currentTime | number |
| volume | number |
| isPlaying | boolean |
| isPaused | boolean |
| isStopped | boolean |
| hasEnded | boolean |
| toNext | boolean |
| toPrev | boolean |
Type Aliases
AudioStatusCallback
(status: AudioStatus): void
