Android OpenTV Player SDK
4.23.3.1610362082
|
Inherits RelativeLayout, MediaPlayerControl, and PlayerInterface.
Public Member Functions | |
NMPVideoView (Context context) | |
Simple constructor to use when creating a view from code. More... | |
NMPVideoView (Context context, AttributeSet attrs) | |
Constructor that is called when inflating a view from XML. More... | |
NMPVideoView (Context context, AttributeSet attrs, int defStyle) | |
Perform inflation from XML and apply a class-specific base style from a theme attribute. More... | |
String | toString () |
Returns a string containing a concise, human-readable description of this object. More... | |
void | setVideoPath (String path) |
Sets the video path. More... | |
void | setVideoPath (String path, int contentType) |
Sets the video path with content type. More... | |
void | setVideoURI (Uri uri) |
Sets the video URI. More... | |
void | stopPlayback () |
Stops playback and releases the media player ready for next playback. More... | |
void | setMediaController (MediaController controller) |
Sets the media controller to be used by the VideoView to interface with playback. More... | |
void | start () |
Starts playback. More... | |
void | pause () |
Pauses playback. More... | |
void | resume () |
Resumes paused content. More... | |
int | getDuration () |
Get the duration of the content. More... | |
int | getCurrentPosition () |
Get the current playback position. More... | |
void | seekTo (int msec) |
Tells the player to seek to a specific time. More... | |
boolean | isPlaying () |
Check if content is currently playing back. More... | |
int | getBufferPercentage () |
Gets the current buffer percentage. More... | |
boolean | canPause () |
Check if the content being played can be paused. More... | |
boolean | canSeekBackward () |
Check if the content being played can seek backwards. More... | |
boolean | canSeekForward () |
Check if the content being played can seek forwards. More... | |
Date | getCurrentDate () |
This method gets the date and time information in HLS content when the HLS tag "EXT-X-PROGRAM-DATE-TIME" is included. More... | |
void | setOnPreparedListener (OnPreparedListener listener) |
Register a callback to be invoked when the media file is loaded and ready to go. More... | |
void | setOnCompletionListener (OnCompletionListener listener) |
Register a callback to be invoked when the end of a media file has been reached during playback. More... | |
void | setOnErrorListener (OnErrorListener listener) |
Register a callback to be invoked when an error occurs during playback or setup. More... | |
void | setOnInfoListener (OnInfoListener listener) |
Register a callback to be invoked when an informational event occurs during playback or setup. More... | |
void | setOnTimedMetaDataAvailableListener (OnNMPTimedMetadataAvailableListener listener) |
Register a callback to be invoked when a selected track has timed metadata available. More... | |
void | setOnOutputControlListener (OutputControlListener listener) |
Register a callback to be invoked when an OutputControl state has changed. More... | |
long [] | getSeekableRangeInfo () |
This method returns the range of the current content that can seek. More... | |
void | setMaxBandwidth (int bandwidth) |
Set the maximum bandwidth for content playback, in bits per second. More... | |
void | setMaxResolution (int width, int height) |
Set the maximum resolution for content playback, in pixels. More... | |
void | setVideoScalingMode (int mode) |
Sets video scaling mode. More... | |
int | getVideoScalingMode () |
return video scaling mode that player are using. More... | |
void | setSourceTimeout (int timeout) |
Set the source timeout for a playback, in seconds. More... | |
int | getSourceTimeout () |
Get the source timeout for a playback, in seconds. More... | |
int | getMaxBandWidth () |
Get the maximum bandwidth. More... | |
NMPTrackInfo [] | getNMPTrackInfo () |
Returns an array of track information. More... | |
void | selectTrack (int index) |
Selects and activates the track referenced by index. More... | |
void | deselectTrack (int index) |
Deactivates the current caption. More... | |
void | setTrackDown (boolean enabled) |
This Allows NMP SDK to switch to a lower bandwidth track if the resolution or bitrate of the current track is too high for the device to play smoothly. More... | |
void | setTrackDownThreshold (float ratio) |
Set track down ratio. More... | |
float | getTrackDownThreshold () |
Get track down threshold ratio. More... | |
boolean | addSubtitleSource (String url, String mimeType, String language) |
Adds an external subtitle source to the content. More... | |
boolean | addSubtitleSource (byte[] content, String mimeType, String language) |
Adds an external subtitle source to the content. More... | |
int | getBufferSize () |
Gets the buffer size. More... | |
void | addTagListener (List< String > xTagsToParse, NMPTagListener xListener) |
Register tags listener. More... | |
void | removeTagListener (NMPTagListener xListener) |
Remove tags listener. More... | |
void | setVolumeGain (int xTargetGain) |
Amplify audio Volume The default value is 1 which means audio volume won't be changed If set input value to be 2 the output volume will be twice of the original The maximum input value is 8 to avoid distortion. More... | |
void | clearTagListeners () |
clear all tags listener More... | |
Replaces the android.widget.VideoView class
NMPVideoView class is used to control playback of audio/video files and streams served from NMP assets server. The NMPVideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.
Note: NMPVideoView does not retain its full state when going into the background. In particular, it does not restore the current play state & play position. Applications should save and restore these on their own in onSaveInstanceState(Bundle) and onRestoreInstanceState(Bundle).
NMPVideoView | ( | Context | context | ) |
Simple constructor to use when creating a view from code.
NMPVideoView | ( | Context | context, |
AttributeSet | attrs | ||
) |
Constructor that is called when inflating a view from XML.
NMPVideoView | ( | Context | context, |
AttributeSet | attrs, | ||
int | defStyle | ||
) |
Perform inflation from XML and apply a class-specific base style from a theme attribute.
boolean addSubtitleSource | ( | String | url, |
String | mimeType, | ||
String | language | ||
) |
Adds an external subtitle source to the content.
An external subtitle/caption source can be added to the content to play back via this method. Currently only SRT subs are supported.
url | the remote url of the subtitles |
mimeType | the mime type of the subtitles (must be "application/x-subrip" currently) |
language | the language identifier of the subtitles (will appear in subtitle track selection) |
boolean addSubtitleSource | ( | byte [] | content, |
String | mimeType, | ||
String | language | ||
) |
Adds an external subtitle source to the content.
An external subtitle/caption source can be added to the content to play back via this method. Currently only SRT subs are supported.
content | the array of subtitle data |
mimeType | the mime type of the subtitles (must be "application/x-subrip" currently) |
language | the language identifier of the subtitles (will appear in subtitle track selection) |
void addTagListener | ( | List< String > | xTagsToParse, |
NMPTagListener | xListener | ||
) |
Register tags listener.
xTagsToParse | the tags list which contains all tags that are required |
xListener | the listener object |
boolean canPause | ( | ) |
Check if the content being played can be paused.
boolean canSeekBackward | ( | ) |
Check if the content being played can seek backwards.
boolean canSeekForward | ( | ) |
Check if the content being played can seek forwards.
void clearTagListeners | ( | ) |
clear all tags listener
void deselectTrack | ( | int | index | ) |
Deactivates the current caption.
index | the index of the track to deactivate |
int getBufferPercentage | ( | ) |
Gets the current buffer percentage.
int getBufferSize | ( | ) |
Gets the buffer size.
Date getCurrentDate | ( | ) |
This method gets the date and time information in HLS content when the HLS tag "EXT-X-PROGRAM-DATE-TIME" is included.
int getCurrentPosition | ( | ) |
Get the current playback position.
int getDuration | ( | ) |
Get the duration of the content.
int getMaxBandWidth | ( | ) |
Get the maximum bandwidth.
0 means no maximum bandwidth limit.
NMPTrackInfo [] getNMPTrackInfo | ( | ) |
Returns an array of track information.
long [] getSeekableRangeInfo | ( | ) |
This method returns the range of the current content that can seek.
This method is used to allow NMPVideoView to support timeshifting playback within HLS Live Streaming content. Based on the amount of content available from the server at a particular time, it determines the seek range within the playing content which also indicates the range where playback may be timeshifted.
This range will be constantly shifting as the live streaming content available from the server changes in real time, so this method will need to be repeatedly called to ensure accurate shifting of playback.
For local content this method will always return the same two values, and the second value indicating the end of the seek range, but this method is most relevant when playing live streaming content
int getSourceTimeout | ( | ) |
Get the source timeout for a playback, in seconds.
This timeout value specifies how long the player waits (in seconds) when no media data is received.
0 - no timeout (infinity)
>0 - timeout in seconds
<0 - not available or not implemented
float getTrackDownThreshold | ( | ) |
Get track down threshold ratio.
int getVideoScalingMode | ( | ) |
return video scaling mode that player are using.
The supported video scaling modes are:
boolean isPlaying | ( | ) |
Check if content is currently playing back.
void pause | ( | ) |
Pauses playback.
void removeTagListener | ( | NMPTagListener | xListener | ) |
Remove tags listener.
xListener | the listener object |
void resume | ( | ) |
Resumes paused content.
void seekTo | ( | int | msec | ) |
Tells the player to seek to a specific time.
msec | The time, in milliseconds, to seek to. Limited to the range returned from getSeekableRangeInfo() |
void selectTrack | ( | int | index | ) |
Selects and activates the track referenced by index.
Note: Must have got the track info first by calling getNMPTrackInfo()
index | the index of the track to activate |
void setMaxBandwidth | ( | int | bandwidth | ) |
Set the maximum bandwidth for content playback, in bits per second.
When set, the NMP SDK will prevent the player from obtaining content streams above this bandwidth limit. If a playlist does not have any streams available with this limit, the lowest bandwidth stream will be used for playback.
Setting a maximum bandwidth of 0 or negative values will remove the limit.
The maximum bandwidth will remain in place until setMaxBandWidth is called again, or until the NMPVideoView is disposed of.
bandwidth | the bandwidth, in bits/second, to cap the content. |
void setMaxResolution | ( | int | width, |
int | height | ||
) |
Set the maximum resolution for content playback, in pixels.
When set, the NMP SDK will prevent the player from obtaining content streams above this resolution limit. If a playlist does not have any streams available with this limit, the lowest resolution stream will be used for playback. The content stream must have both width and height values below the set limits for a stream to be allowed
Setting a maximum resolution of 0 x 0 will remove the limit.
The maximum resolution will remain in place until setMaxResolution is called again, or until the NMPVideoView is disposed of.
width | the width, in pixels, to cap the content. |
height | the height, in pixels, to cap the content. |
void setMediaController | ( | MediaController | controller | ) |
Sets the media controller to be used by the VideoView to interface with playback.
controller | the MediaController object to be used |
void setOnCompletionListener | ( | OnCompletionListener | listener | ) |
Register a callback to be invoked when the end of a media file has been reached during playback.
listener | The callback that will be run |
void setOnErrorListener | ( | OnErrorListener | listener | ) |
Register a callback to be invoked when an error occurs during playback or setup.
listener | The callback that indicate an error will be run: |
boolean onError(MediaPlayer mp, int what, int extra);
mp the NMPMediaPlayer the error pertains to
what the type of error that has occurred:
extra an extra code, specific to the error. Typically implementation dependent.
void setOnInfoListener | ( | OnInfoListener | listener | ) |
Register a callback to be invoked when an informational event occurs during playback or setup.
listener | The callback that indicate an info or a warning, will be run: |
boolean onInfo(MediaPlayer mp, int what, int extra):
mp the MediaPlayer the info pertains to.
what the type of info or warning.
extra an extra code, specific to the info. Typically implementation dependent.
when 'what' is NMPMediaPlayer.MEDIA_INFO_STALLED, Media playback is continuous pausing internally because of network is stalled
when 'what' is NMPMediaPlayer.MEDIA_INFO_METADATA_UPDATE, 'extra' could be
void setOnOutputControlListener | ( | OutputControlListener | listener | ) |
Register a callback to be invoked when an OutputControl state has changed.
listener | The callback that will indicate when OutputControl state has changed |
void setOnPreparedListener | ( | OnPreparedListener | listener | ) |
Register a callback to be invoked when the media file is loaded and ready to go.
listener | The callback that will be run |
void setOnTimedMetaDataAvailableListener | ( | OnNMPTimedMetadataAvailableListener | listener | ) |
Register a callback to be invoked when a selected track has timed metadata available.
Currently only HTTP live streaming data URI's embedded with timed ID3 tags generates NMPTimedMetaData.
listener | the callback that will be run |
void setSourceTimeout | ( | int | timeout | ) |
Set the source timeout for a playback, in seconds.
For supported stream types, this specifies how long the player waits when no media data is received. For unsupported stream types, this timeout value is ignored.
timeout |
0 - no timeout (infinity)
>0 - timeout in seconds
<0 - not allowed (stream type does not support setting a timeout)
void setTrackDown | ( | boolean | enabled | ) |
This Allows NMP SDK to switch to a lower bandwidth track if the resolution or bitrate of the current track is too high for the device to play smoothly.
Under normal operation, NMP SDK switches tracks based solely on current network conditions. When this property is enabled, NMP SDK will also switch to a lower bandwidth track if too many frames are skipped during playback. This is useful for content that is targeted for a variety of devices, some of which may not be powerful enough to handle the higher quality streams. Enable track down by passing in true, NMP SDK will require that at least the ratio of the decoded frames be displayed which specified by the second parameter.
enabled | Flag of enable or disable track down. |
void setTrackDownThreshold | ( | float | ratio | ) |
Set track down ratio.
ratio | ratio of frames dropped, ranging [0.0f, 1.0f]. |
void setVideoPath | ( | String | path | ) |
Sets the video path.
path | the String based path to the content to be played back. |
NullPointerException | if the path parameter is null |
void setVideoPath | ( | String | path, |
int | contentType | ||
) |
Sets the video path with content type.
path | the String based path to the content to be played back. |
contentType | indicate the stream content type. The available values are: |
NullPointerException | if the path parameter is null |
void setVideoScalingMode | ( | int | mode | ) |
Sets video scaling mode.
To make the target video scaling mode effective during playback, this method must be called after data source is set. If not called, the default video scaling mode is MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT.
The supported video scaling modes are:
mode | target video scaling mode. Most be one of the supported video scaling modes; otherwise, IllegalArgumentException will be thrown. |
void setVideoURI | ( | Uri | uri | ) |
Sets the video URI.
uri | the URI to the content to be played back. |
void setVolumeGain | ( | int | xTargetGain | ) |
Amplify audio Volume The default value is 1 which means audio volume won't be changed If set input value to be 2 the output volume will be twice of the original The maximum input value is 8 to avoid distortion.
xTargetGain | the target gain |
void start | ( | ) |
Starts playback.
void stopPlayback | ( | ) |
Stops playback and releases the media player ready for next playback.
String toString | ( | ) |
Returns a string containing a concise, human-readable description of this object.