NativeScript plugin to play and record audio files for Android and iOS.
Uses the following native classes:
npm install nativescript-audio
Method | Description |
---|---|
TNSRecorder.CAN_RECORD() : boolean |
Determine if ready to record. |
start({ filename: string, errorCallback?: Function, infoCallback?: Function }) : Promise |
Start recording file. |
stop() : void |
Stop recording. |
dispose() : void |
Free up system resources when done with recorder. |
Method | Description |
---|---|
playFromFile( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) : Promise |
Play from a file. |
playFromUrl( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) : Promise |
Play from a url. |
pause() : void |
Pause playback. |
seekTo(time:number) : Promise<boolean> |
Seek to position. |
dispose() : void |
Free up resources when done playing audio. |
isAudioPlaying() : boolean |
Determine if player is playing. |
getAudioTrackDuration() : Promise |
duration of media file assigned to mediaPlayer |
TNS
stands for Telerik NativeScript
iOS uses classes prefixed with NS
(stemming from the NeXTSTEP days of old):
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
To avoid confusion with iOS native classes, TNS
is used instead.