Audio playback
npm install ionic-audio-plugin
npx cap sync
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)
}
}
echo(options: { value: string; }) => Promise<{ value: string; }>
Param |
Type |
options |
{ value: string; } |
Returns: Promise<{ value: string; }>
play(options: PlayOptions) => Promise<void>
resume() => Promise<void>
seekTo(options: SeekToOptions) => Promise<void>
status(callback: AudioStatusCallback) => void
Prop |
Type |
url |
string |
title |
string |
album |
string |
artwork |
string |
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 |
(status: AudioStatus): void