Media

The Media API provides the ability to record and play back audio files on a device.

Usage
//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();

Classes


Media

create
 create(src: string): Promise <MediaObject>

Open a media file.


PARAMETERS
src: stringA URI containing the audio content.

RETURN
returns: Promise <MediaObject>
PERMISSIONS

This method requires STORAGE Permission set on Fawi Office - publish settings.

getCurrentAmplitude
 getCurrentAmplitude(): Promise <int>

Returns the current amplitude within an audio file.


RETURN
returns: Promise <int>
getCurrentPosition
 getCurrentPosition(): Promise <int>

Returns the current position within an audio file. Also updates the Media object's position parameter.


RETURN
returns: Promise <int>
getDuration
 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.


RETURN
returns: Promise <int>
pause
 pause(): Promise <any>

Pauses playing an audio file.


RETURN
returns: Promise <any>
play
 play(): Promise <any>

Starts or resumes playing an audio file.


RETURN
returns: Promise <any>
release
 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.


RETURN
returns: Promise <any>
seekTo
 seekTo(milliseconds: int): Promise <any>

Sets the current position within an audio file.


PARAMETERS
milliseconds: int

RETURN
returns: Promise <any>
setVolume
 setVolume(volume: int): Promise <any>

Set the volume for an audio file.


PARAMETERS
volume: int

RETURN
returns: Promise <any>
startRecord
 startRecord(): Promise <any>

Starts recording an audio file.


RETURN
returns: Promise <any>
PERMISSIONS

This method requires MICROPHONE and STORAGE Permissions set on Fawi Office - publish settings.

stop
 stop(): Promise <any>

Stops playing an audio file.


RETURN
returns: Promise <any>
stopRecord
 stopRecord(): Promise <any>

Stops recording an audio file.


RETURN
returns: Promise <any>

Interfaces

MediaError

interface MediaError {
    code: number;
    message : string;
}

Enumerations

MediaStatus

enum MediaStatus {
    MEDIA_NONE : 0,
    MEDIA_STARTING : 1,
    MEDIA_RUNNING : 2,
    MEDIA_PAUSED : 3,
    MEDIA_STOPPED : 4
    
}

MediaErrorCode

enum MediaErrorCode {
    MEDIA_ERR_NONE_ACTIVE : 0,
    MEDIA_ERR_ABORTED : 1,
    MEDIA_ERR_NETWORK : 2,
    MEDIA_ERR_DECODE : 3,
    MEDIA_ERR_NONE_SUPPORTED : 4,
    
}