The Media API provides the ability to record and play back audio files on a device.
//create a Media file object
var myRecord = Media.create('MyRec.mp3');
//start recording a audio file
myRecord.startRecord();
...
//stop recording a audio file previously started
myRecord.stopRecord();
...
//start play a audio file
myRecord.play();
...
//release a audio file
myRecord.release();
setMyRecord(window.Media.create("MyRec.mp3"));
...
myRecord.startRecord();
...
myRecord.stopRecord();
...
myRecord.play();
...
myRecord.release();
this.myrecord = window.Media.create("MyRec.mp3");
...
this.myrecord.startRecord();
...
this.myrecord.stopRecord();
...
this.myrecord.play();
...
this.myrecord.release();
this.myrecord = (<any>window).Media.create("MyRec.mp3");
...
this.myrecord.startRecord();
...
this.myrecord.stopRecord();
...
this.myrecord.play();
...
this.myrecord.release();
myrecord = window.Media.create("MyRec.mp3");
...
myrecord.startRecord();
...
myrecord.stopRecord();
...
myrecord.play();
...
myrecord.release();
create(src: string): Promise <MediaObject>
Open a media file.
getCurrentAmplitude(): Promise <int>
Returns the current amplitude within an audio file.
getCurrentPosition(): Promise <int>
Returns the current position within an audio file. Also updates the Media object's position parameter.
getDuration(): Promise <int>
Get duration of an audio file.
The duration is only set for audio that is playing, paused or stopped.
If the duration is unknown, it returns a value of -1.
release(): Promise <any>
Releases the underlying operating system's audio resources. Applications should call the release function for any Media resource that is no longer needed.
seekTo(milliseconds: int): Promise <any>
Sets the current position within an audio file.
setVolume(volume: int): Promise <any>
Set the volume for an audio file.
startRecord(): Promise <any>
Starts recording an audio file.
interface MediaError { code: number; message : string; }
enum MediaStatus { MEDIA_NONE : 0, MEDIA_STARTING : 1, MEDIA_RUNNING : 2, MEDIA_PAUSED : 3, MEDIA_STOPPED : 4 }
enum MediaErrorCode { MEDIA_ERR_NONE_ACTIVE : 0, MEDIA_ERR_ABORTED : 1, MEDIA_ERR_NETWORK : 2, MEDIA_ERR_DECODE : 3, MEDIA_ERR_NONE_SUPPORTED : 4, }