You are here: Media API
The Media API enables your app to play and record audio files. It contains the following Namespace and objects:
|voltmx.media.createFromFile||Creates a media object from a media file on the device.|
|voltmx.media.createFromUri||Creates a media object that plays a remote audio file across the network.|
|voltmx.media.record||Creates a record object that your app can use to record audio.|
|pause||Pauses the playback of a media file.|
|play||Plays a media file.|
|releaseMedia||Releases the memory and resources held by the media object.|
|seek||Sets the current playback position to a specific spot in the media file.|
|setCallbacks||Associates callback functions with the media object.|
|stop||Stops the playback of a media file.|
|data||Holds the data object that contains the sound associated with the media object.|
|duration||Contains the duration of the audio in seconds.|
|isPlaying||Contains a Boolean value that indicates whether or not the audio is currently playing.|
|volume||Contains the current volume level.|
|startRecording||Stops the current recording.|
|stopRecording||Starts recording audio.|
Create a media object from an existing audio file using the voltmx.media.createFromFile function. To control the audio output, use the methods of media object such as play, pause, and stop. If you want to play a remote audio file across the network, create a media object by using the voltmx.media.createFromUri function. You can move the playback position to a desired point using the seek method. Using the releaseMedia method, you can delete the resources held by the media object and save memory. Further, to see a response based on a specific event, associate callback functions with the media object using the setCallbacks method.
You can configure the duration, volume, data properties of the audio file and find whether a specific audio is playing using the isPlaying property.
Further, you can record audio files using the record object. To start recording an audio file, use the startRecording method and to stop recording the audio file, use the stopRecording object.
To view the functionality of the Media API in action, download the sample application from the link below. Once the application is downloaded, build and preview the application using the Volt MX App.