1
1
# NativeScript-Audio
2
- NativeScript plugin to play and record audio files.
2
+ NativeScript plugin to play and record audio files for Android and iOS .
3
3
4
- * Currently Android only, iOS is in the works. *
4
+ Uses the following native classes:
5
5
6
- [ Android Media Recorder Docs] ( http://developer.android.com/reference/android/media/MediaRecorder.html )
6
+ #### Android
7
+
8
+ * [ Player] ( http://developer.android.com/reference/android/media/MediaPlayer.html )
9
+ * [ Recorder] ( http://developer.android.com/reference/android/media/MediaRecorder.html )
10
+
11
+ #### iOS
12
+
13
+ * [ Player] ( https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/ )
14
+ * [ Recorder] ( https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/ )
7
15
8
16
## Installation
9
17
` npm install nativescript-audio `
@@ -12,41 +20,38 @@ NativeScript plugin to play and record audio files.
12
20
13
21
![ AudioExample] ( screens/audiosample.gif )
14
22
15
-
16
23
## API
17
24
18
- #### * Recording*
19
-
20
- ##### canDeviceRecord() - * Promise*
21
- - retruns: * boolean*
22
-
23
- ##### startRecorder( { filename: string, errorCallback?: Function, infoCallback?: Function } ) - * Promise*
24
- - returns: * recorder* (android.media.MediaRecorder)
25
-
26
- ##### stopRecorder(recorder: recorder object from startRecorder)
27
-
25
+ #### TNSRecorder
28
26
29
- ##### disposeRecorder(recorder: recorder object from startRecorder)
30
- - * Free up system resources when done with recorder*
27
+ Method | Description
28
+ -------- | ---------
29
+ ` TNSRecorder.CAN_RECORD() ` : ` boolean ` | Determine if ready to record.
30
+ ` start({ filename: string, errorCallback?: Function, infoCallback?: Function }) ` : ` Promise ` | Start recording file.
31
+ ` stop() ` : ` void ` | Stop recording.
32
+ ` dispose() ` : ` void ` | Free up system resources when done with recorder.
31
33
34
+ #### TNSPlayer
32
35
33
- #### * Playing*
36
+ Method | Description
37
+ -------- | ---------
38
+ ` playFromFile( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) ` : ` Promise ` | Play from a file.
39
+ ` playFromUrl( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) ` : ` Promise ` | Play from a url.
40
+ ` pause() ` : ` void ` | Pause playback.
41
+ ` dispose() ` : ` void ` | Free up resources when done playing audio.
42
+ ` isAudioPlaying() ` : ` boolean ` | Determine if player is playing.
43
+ ` getAudioTrackDuration() ` : ` Promise ` | duration of media file assigned to mediaPlayer
34
44
35
- ##### playFromFile( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) - * Promise*
36
- - returns mediaPlayer (android.media.MediaPlayer)
45
+ ## Why the TNS prefixed name?
37
46
38
- ##### playFromUrl( { audioFile: string, completeCallback?: Function, errorCallback?: Function, infoCallback?: Function; } ) - * Promise*
39
- - returns mediaPlayer (android.media.MediaPlayer)
47
+ ` TNS ` stands for ** T** elerik ** N** ative** S** cript
40
48
41
- ##### pausePlayer(mediaPlayer) - * Promise *
42
- - return boolean
49
+ iOS uses classes prefixed with ` NS ` (stemming from the [ NeXTSTEP ] ( https://en.wikipedia.org/wiki/NeXTSTEP ) days of old):
50
+ https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
43
51
44
- ##### disposePlayer(mediaPlayer)
45
- -- Free up resources when done playing audio with this instance of your mediaPlayer
52
+ To avoid confusion with iOS native classes, ` TNS ` is used instead.
46
53
47
- ##### isAudioPlaying(mediaPlayer) - * Promise*
48
- - returns boolean
54
+ # License
49
55
50
- ##### getAudioTrackDuration(mediaPlayer) - * Promise*
51
- - returns string - duration of media file assigned to mediaPlayer
56
+ [ MIT] ( /LICENSE )
52
57
0 commit comments