AMP Android SDK: Basic playback methods

Document created by Herberth Alvarado Champion on Aug 11, 2016Last modified by Herberth Alvarado Champion on Apr 9, 2017
Version 5Show Document
  • View in full screen mode

Maintainer: Orlando Sanchez Martinez

This document is part of AMP Android SDK 

 

These are the methods you can use in your application for supporting multimedia playback: 

 

Method
Description
play(MediaResource)
Plays the MediaResource returned by the callback, generated from a stream in prepareResource(VIDEO_URL);
play(MediaResource, position)
Plays the MediaResource, starting at the specified position (in seconds).
playMuted(MediaResource)
Plays the MediaResource muted, returned by the callback, generated from a stream in prepareResource(VIDEO_URL);
playMuted(MediaResource, position)
Plays the MediaResource muted, starting at the specified position (in seconds).
playAudio(MediaResource)
Plays an audio-only stream. This method should be used when developing an application that does not implement a video layer; for example, a service to reproduce audio streams in the background.
playAudio(MediaResource, position)
Plays an audio-only stream, starting at the specified position (in seconds).
pause()
Pauses the playback. Doesn’t work when player is seeking or switching bitrates.
resume()
Resumes the playback at the latest position. Doesn’t have any effect if playback is not in the paused state. The developer does not need to save the current position, the SDK does that internally.
stop()
It stops the playback, resets the current playback position and triggers the PLAYER_EVENT_TYPE_FINISHED event. To start the video again, play(MediaResource) must be called.
onDestroy()

It stops the playback, shuts down the decoding processes and resets the Activity reference to avoid potential memory leaks.

mute()
It mutes the audio of the playback.
unmute()
It unmutes the audio of the playback.
seek(position)
Does a seek operation to the specified time position, indicated in seconds as an absolute position (0 is the start of the stream). This method shouldn’t be called until the PLAYER_EVENT_TYPE_START_PLAYING event is raised.
setFullScreen(mode)
Enables/Disables fullscreen mode. When fullscreen mode is enabled, Android SDK will render the video content using as much space as possible, in the VideoPlayerView object. This doesn’t mean the SDK is going to resize the VideoPlayerView object to fill the entire screen. If this is required, the application should be responsible of doing it.
getDuration() [int]
Returns the total duration of the media resource in seconds. For a live stream, it returns 0 seconds.
getTimePosition() [int]
Returns the current playback position, in seconds. For live streams, it returns the number of seconds since the playback started and its value is reset whenever the user does a seeking or bitrate change operation.
getTimePositionMS() [long]
Returns the current playback position, in milliseconds. For live streams returns the number of milliseconds since the playback started and its value is reset whenever the user does a seeking or bitrate change operation.
isPlaying() [boolean]
Returns true if playback is in progress; false otherwise.
isPaused() [boolean]
Returns true if playback is paused; false otherwise.
isSeeking() [boolean]
Returns true if a seeking operation is in progress; false otherwise.
isFullScreen() [boolean]
Returns true if the VideoPlayerView object is in fullscreen mode; false otherwise.
isFinished() [boolean]
Returns true if the playback has finished (reached the end of the stream); false otherwise.
isLive() [boolean]
Returns true if a live stream is being played; false otherwise.
isError() [boolean]
Returns true if VideoPlayerView object is in an error state; false otherwise.

 

 

This document is part of AMP Android SDK 

Attachments

    Outcomes