public interface Media
Media control interface allows for media playback, recording. To get an instance of this interface (implemented by the native port) see the MediaManager class.
The sample code below demonstrates simple video playback.
The code below demonstrates capturing audio using the Capture API and playing back audio files using the Media API:
The code below demonstrates capturing audio and playing back audio using the Media, MediaManager and MediaRecorderBuilder APIs, as alternative and more customizable approach than using the Capture API:
MediaManager
Modifier and Type | Field and Description |
---|---|
static String |
VARIABLE_BACKGROUND_ALBUM_COVER
Write only variable that can be used with setVariable to pass the album cover Image to the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
|
static String |
VARIABLE_BACKGROUND_ARTIST
Write only variable that can be used with setVariable to pass the artist name to the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
|
static String |
VARIABLE_BACKGROUND_DURATION
Write only variable that can be used with setVariable to pass the duration for the media as a Long object to the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
|
static String |
VARIABLE_BACKGROUND_POSITION
Write only variable that can be used with setVariable to pass the position in the media (Long object) to the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
|
static String |
VARIABLE_BACKGROUND_SUPPORTED
Read only variable that can be used with getVariable to query whether the
native layer supports displaying the currently playing media information
in the lock screen.
|
static String |
VARIABLE_BACKGROUND_TITLE
Write only variable that can be used with setVariable to pass a title for the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
|
static String |
VARIABLE_NATIVE_CONTRLOLS_EMBEDDED
Write-only variable that can be used with getVariable() to set whether this
video should include embedded native controls.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Stops the audio playback and cleans up the resources related to it immediately.
|
int |
getDuration()
Returns the length in milliseconds of the audio file or -1 if not known
|
int |
getTime()
Returns the time in milliseconds in the audio file or -1 if not known
|
Object |
getVariable(String key)
Allows querying platform specific information from the media object
|
Component |
getVideoComponent()
Gets the VideoComponent of this Video.
|
int |
getVolume()
Returns the media playback volume in percentage
|
boolean |
isFullScreen()
This method returns true if this video is in full screen mode.
|
boolean |
isNativePlayerMode()
Returns true if this Video Media is in Native player mode.
|
boolean |
isPlaying()
Returns true if the media is currently playing or recording
|
boolean |
isVideo()
This method returns true if this is a Video Media
|
void |
pause()
Pauses (actually stops) the playback or the recording of the media file
|
void |
play()
Starts playing or recording the media file
|
void |
prepare()
Optional call that allows the caller to prepare the upcoming media player.
|
void |
setFullScreen(boolean fullScreen)
Sets the Media to be displayed full screen, make sure the
getVideoComponent() is called on the Video Component is added to the
current Form
|
void |
setNativePlayerMode(boolean nativePlayer)
By calling this the Media (if it's a Video) will be played full screen
on the native Player of the device.
|
void |
setTime(int time)
Sets the position in the audio file or doesn't effect if not supported
|
void |
setVariable(String key,
Object value)
Allows for platform specific enhancements for media playback
|
void |
setVolume(int vol)
Sets the media playback volume in percentage
|
static final String VARIABLE_BACKGROUND_TITLE
static final String VARIABLE_BACKGROUND_ARTIST
static final String VARIABLE_BACKGROUND_DURATION
static final String VARIABLE_BACKGROUND_ALBUM_COVER
static final String VARIABLE_BACKGROUND_POSITION
static final String VARIABLE_BACKGROUND_SUPPORTED
static final String VARIABLE_NATIVE_CONTRLOLS_EMBEDDED
void play()
void pause()
void prepare()
Note: On some platforms (iOS), the poster frame and native embedded controls will not appear for the video until you call this method, otherwise.
void cleanup()
int getTime()
void setTime(int time)
time
- in millisecondsint getDuration()
void setVolume(int vol)
vol
- the volume for media playbackint getVolume()
boolean isPlaying()
Component getVideoComponent()
boolean isVideo()
boolean isFullScreen()
void setFullScreen(boolean fullScreen)
fullScreen
- void setNativePlayerMode(boolean nativePlayer)
boolean isNativePlayerMode()
void setVariable(String key, Object value)
key
- the key to set to the media that is platform specificvalue
- the value