Skip to content

NathanWalker/nativescript-audio

 
 

Repository files navigation

npm npm

NativeScript-Audio

NativeScript plugin to play and record audio files for Android and iOS.

Uses the following native classes:

Android

iOS

Installation

npm install nativescript-audio

Sample Screen

AudioExample

API

TNSRecorder

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.

TNSPlayer

Method Description
playFromFile( { audioFile: string, loop: boolean, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ): Promise Play from a file.
playFromUrl( { audioFile: string, loop: boolean, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ): Promise Play from a url.
pause(): void Pause playback.
resume(): void Resume 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

Why the TNS prefixed name?

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.

License

MIT

About

NativeScript plugin to record and play audio.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.8%
  • CSS 2.2%