Arc Media Player
This class is used to interact with the video capabilities of the SDK.
How does it relate to other important Video SDK classes?
ArcMediaPlayerConfig - ArcVideoManager - ArcVideoStream
What are the core components that make it up?
ArcMediaPlayerConfig - ArcVideoManager - ArcVideoStream
How is this class used?
var mediaPlayer = ArcMediaPlayer.instantiate(this)
mediaPlayer.trackMediaEvents(object: ArcVideoEventsListener() {
override fun onVideoTrackingEvent(type: TrackingType?, videoData: TrackingVideoTypeData?) {
when(type) {
TrackingType.ON_PLAY_STARTED -> {
//do something for playback started
}
TrackingType.ON_PLAY_COMPLETED -> {
//do something for playback ended
}
}
}
override fun onSourceTrackingEvent(type: TrackingType?, source: TrackingSourceTypeData?) {
}
override fun onError(type: TrackingType?, video: TrackingErrorTypeData?) {
}
override fun onAdTrackingEvent(type: TrackingType?, adData: TrackingAdTypeData?) {
val arcAd = adData.arcAd ?: return
when (type) {
TrackingType.AD_CLICKTHROUGH -> {
}
TrackingType.MIDROLL_AD_STARTED -> {
}
TrackingType.MIDROLL_AD_COMPLETED -> {
}
}
})
mediaPlayer.trackErrors(object: ArcVideoSDKErrorListener {
override fun onError(errorType: ArcVideoSDKErrorType, message: String, value: Any?) {
}
})
}
//Using an ArcMediaPlayerConfig object
val config = ArcMediaPlayerConfig.Builder()
.setActivity(activity)
.setVideoFrame(mVideoContainer)
.setServerSideAds(true)
.setClientSideAds(true)
......
.showProgressBar(true)
.showClosedCaption(true)
.setShowClosedCaptionTrackSelection(false)
.addAdParam("sz", "400x300")
......
.build()
mediaPlayer.configureMediaPlayer(config)
//Configuring media player directly
mediaPlayer.setActivity(activity)
mediaPlayer.setVideoFrame(mVideoContainer)
mediaPlayer.initMedia(stream)
mediaPlayer.displayVideo()
mediaPlayer.setServerSideAds(true)
mediaPlayer.setClientSideAds(true)
....
mediaPlayer.initMedia(stream)
mediaPlayer.displayVideo()
Types
Functions
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Add an adParam key/value pair to be passed to MediaTailor when enabling server side ads. Multiple calls can be made to this method and each parameter will be added to the call. This method takes a key and a value and will be added to the call as a JSON entry of the format { “adParams” : { “key1”: “value1”, “key2”: “value2” } }
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. One or more views can be added on top of the video view using the configuration option addOverlay(). This method takes a tag name for the view as well as the view. The client app will still have a pointer to the overlays so they can then control the visibility or other parameters of the views from within the client code. This method can can be called multiple times in order to add multiple overlays.
Add a video to the player that will be played after the last video is played. This effectively creates a playlist or adds a video to the end of an existing playlist.
Add a video and a corresponding ad to be played after the last video is played. Works the same as .addVideo with the addition of an ad url.
Configures the media player
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Enable debug logging
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether picture-in-picture is enabled for the video.
Programmatically exits picture-in-picture if it is playing This is for pressing x to close app from picture-in-picture mode
Retrieve the overlay view associated with a tag
Programmatically hides the control bar on the media player
Initialize the player with a media object
Initialize the player with a virtual channel url
Initialize the player with a list of media objects. The objects will be played consecutively.
Initialize the player with a media object and an ad URL. This will play the video with the ad.
Initialize the player with a list of media objects and list of corresponding ad urls. Each ad URL will be associated with its corresponding video based upon order in the list. videos0 will associate with adUrls0, videos1 will be associated with adUrls1, etc.
Initialize the player with a media object
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. When controls are hidden in the control bar the visibility is set to GONE so the space is reclaimed during the next layout pass. Depending on how the custom control bar is set up this can cause controls to shift. Setting this to true will cause the control visibility to be set to INVISIBLE so the space will not be reclaimed during the next layout pass.
Call when onBackPressed is called on the parent activity.
Call this from the override method in the parent activity
Programmatically stops picture-in-picture if it is playing This is for returning to previous mode from picture-in-picture mode
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Set the parent activity of the media player
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. This can be used to set the same ad url for all videos. It is better to use one of the initMedia() methods that take an ad string.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether the playback controls are automatically shown when playback starts, pauses, ends, or fails
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets the flag to automatically start playback when the video is ready.
Change the drawable used for the closed caption button on the control bar
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets if closed caption starts on, off or the device default. Set to on and CC will display when playback starts, set to off and CC will not show when playback starts, set to default and the start mode will follow the accessibility settings of the device.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Turn client side ads on/off. This only works with live feeds.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets the number of seconds to show the controls before hiding them.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Enable ads. If set to false then ads will not be shown.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether the skip button on skippable ads is focused when it appears. This is for FireTv implementations.
Programmatically turn fullscreen on or off
For FireTV implementations, sets the listener for remote control keypresses when in fullscreen
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. An ArcVideoStreamObject can return multiple streams that each have a different video type and bit rate. The stream to play will be chosen based on a preferred stream type and a maximum bit rate that is desired. The preferred streams have a hierarchy that is HLS, TS, MP4, GIF, GIF-MP4. The algorithm to choose the correct stream will loop through all available streams of the preferred type. Of those it will find the one that does not exceed the given max bit rate. If a stream of the preferred type does not exist then it will go to the next preferred stream type and repeat the search, working its way down until it finds a stream that does not exceed the bit rate. For example, if the preferred type is set to TS and there are no TS streams in the object then it will repeat the search using MP4, then GIF, then GIF-MP4.
For FireTV implementations, sets the listener for remote control keypresses
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. An ArcVideoStreamObject can return multiple streams that each have a different video type and bit rate. The stream to play will be chosen based on a preferred stream type and a maximum bit rate that is desired. The preferred streams have a hierarchy that is HLS, TS, MP4, GIF, GIF-MP4. The algorithm to choose the correct stream will loop through all available streams of the preferred type. Of those it will find the one that does not exceed the given max bit rate. If a stream of the preferred type does not exist then it will go to the next preferred stream type and repeat the search, working its way down until it finds a stream that does not exceed the bit rate. For example, if the preferred type is set to TS and there are no TS streams in the object then it will repeat the search using MP4, then GIF, then GIF-MP4.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Turn server side ads on/off. This only works with live feeds.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Determines if the closed caption track selection dialog is displayed when CC button is pressed or if CC mode toggles on/off.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether the video start with the audio muted.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets the video frame object that will display the player
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Adds a list of views that will be hidden when PIP is activated. This is used to hide any views in the Activity or Fragment such as action bar, buttons, etc that are not the actual video view.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show the closed caption button on the control bar
Programmatically show the control bar on the media player
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show or hide the video duration countdown at the right side of the progress bar
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show or hide the progress bar.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show or hide the seek buttons on the control bar.
Programmatically toggles controller auto show, if true will use config values used to disable controls during pip
Programmatically toggle the closed captioning on or off
Used to track errors being returned.
Used to track the various media events being returned.
Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Fullscreen can be displayed either as a dialog that takes up the full device screen or by setting the layout parameters of the ArcVideoFrame to match_parent for both width and height. The preference depends on how the layout is built. If the video frame is a direct child of the root layout then a dialog is not necessary. If the video frame is not a direct child, i.e. it is the child of another view inside of the root view, setting the layout parameters will only expand it to the size of its parent view and will not make it full screen but rather the full size of the parent view. In this case a dialog should be used. This is provided to allow flexibility based upon how the layout is built.