ArcMediaPlayer

class ArcMediaPlayer

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

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addAdParam(key: String, value: String): ArcMediaPlayer

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” } }

Link copied to clipboard
fun addOverlay(tag: String, overlay: View): ArcMediaPlayer

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.

Link copied to clipboard
fun addVideo(video: ArcVideoStream?)

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.

fun addVideo(video: ArcVideoStream?, adUrl: String?)

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.

Link copied to clipboard
fun configureMediaPlayer(config: ArcXPVideoConfig?): ArcMediaPlayer

Configures the media player

Link copied to clipboard
fun dispatchKeyEvent(event: KeyEvent): Boolean
Link copied to clipboard
fun displayVideo()
Link copied to clipboard
fun enableLogging(): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Enable debug logging

Link copied to clipboard
fun enablePip(enable: Boolean): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether picture-in-picture is enabled for the video.

Link copied to clipboard
fun exitAppFromPip()

Programmatically exits picture-in-picture if it is playing This is for pressing x to close app from picture-in-picture mode

Link copied to clipboard
fun finish()

Call to clean up video resources.

Link copied to clipboard
fun getOverlay(tag: String?): View

Retrieve the overlay view associated with a tag

Link copied to clipboard
fun hideControls()

Programmatically hides the control bar on the media player

Link copied to clipboard
fun initMedia(video: ArcVideo?): ArcMediaPlayer
fun initMedia(video: ArcVideoStream?): ArcMediaPlayer

Initialize the player with a media object

fun initMedia(arcVideoStreamVirtualChannel: ArcVideoStreamVirtualChannel): ArcMediaPlayer

Initialize the player with a virtual channel url

fun initMedia(videos: List<ArcVideoStream?>?): ArcMediaPlayer

Initialize the player with a list of media objects. The objects will be played consecutively.

fun initMedia(video: ArcVideoStream?, adUrl: String?): ArcMediaPlayer

Initialize the player with a media object and an ad URL. This will play the video with the ad.

fun initMedia(videos: List<ArcVideoStream?>?, adUrls: List<String?>?): ArcMediaPlayer

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.

Link copied to clipboard
fun initMediaEvents(trackEvents: ArcVideoEventsListener?): ArcMediaPlayer
Link copied to clipboard
fun initMediaWithShareURL(video: ArcVideoStream?, shareURL: String): ArcMediaPlayer

Initialize the player with a media object

Link copied to clipboard
fun isMinimalControlsNow(): Boolean
Link copied to clipboard
fun isPipEnabled(): Boolean
Link copied to clipboard
fun keepControlsSpaceOnHide(keep: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun onBackPressed(): Boolean

Call when onBackPressed is called on the parent activity.

Link copied to clipboard
fun onDestroy()

Call this from onDestroy() in the activity if Chromecast is enabled.

Link copied to clipboard
fun onPause()

Lifecycle method called from parent activity

Link copied to clipboard
fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?)

Call this from the override method in the parent activity

Link copied to clipboard
fun onResume()

Lifecycle method called from parent activity

Link copied to clipboard
fun onStop()

Lifecycle method called from parent activity

Link copied to clipboard
fun pause()

Programmatically pause the player

Link copied to clipboard
fun playVideo()

Start playing the video

Link copied to clipboard
fun resume()

Programmatically resume the player.

Link copied to clipboard
fun returnToNormalFromPip()

Programmatically stops picture-in-picture if it is playing This is for returning to previous mode from picture-in-picture mode

Link copied to clipboard
fun seekTo(ms: Int)

Seek to a point in the video

Link copied to clipboard
fun setActivity(activity: Activity?): ArcMediaPlayer
fun setActivity(activity: AppCompatActivity?): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Set the parent activity of the media player

Link copied to clipboard
fun setAdConfigUrl(url: String?): ArcMediaPlayer

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.

Link copied to clipboard
fun setAutoShowControls(show: Boolean): ArcMediaPlayer

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

Link copied to clipboard
fun setAutoStartPlay(play: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setCcButtonDrawable(@DrawableRes ccButtonDrawable: Int): Boolean

Change the drawable used for the closed caption button on the control bar

Link copied to clipboard
fun setCcStartMode(mode: ArcXPVideoConfig.CCStartMode): ArcMediaPlayer

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.

Link copied to clipboard
fun setClientSideAds(set: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setControlsShowTimeoutMs(ms: Int): ArcMediaPlayer

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.

Link copied to clipboard
fun setEnableAds(enable: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setErrorListener(listener: ArcVideoSDKErrorListener?): ArcMediaPlayer
Link copied to clipboard
fun setFocusSkipButton(focus: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setFullscreen(full: Boolean)

Programmatically turn fullscreen on or off

Link copied to clipboard
fun setFullscreenKeyListener(listener: ArcKeyListener?)

For FireTV implementations, sets the listener for remote control keypresses when in fullscreen

Link copied to clipboard
fun setMaxBitRate(rate: Int): ArcMediaPlayer

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.

Link copied to clipboard
fun setPlayerKeyListener(listener: ArcKeyListener?)

For FireTV implementations, sets the listener for remote control keypresses

Link copied to clipboard

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.

Link copied to clipboard
fun setServerSideAds(set: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setShowClosedCaptionTrackSelection(show: Boolean): ArcMediaPlayer

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.

Link copied to clipboard
fun setStartMuted(muted: Boolean): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets whether the video start with the audio muted.

Link copied to clipboard
fun setVideoFrame(videoFrame: ArcVideoFrame?): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Sets the video frame object that will display the player

Link copied to clipboard
fun setViewsToHide(vararg views: View?): ArcMediaPlayer

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.

Link copied to clipboard
fun setVolume(volume: Float)

Programmatically set the volume of the player

Link copied to clipboard
fun showClosedCaption(enable: Boolean): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show the closed caption button on the control bar

Link copied to clipboard
fun showControls()

Programmatically show the control bar on the media player

Link copied to clipboard
fun showCountdown(show: Boolean): ArcMediaPlayer

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

Link copied to clipboard
fun showProgressBar(show: Boolean): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show or hide the progress bar.

Link copied to clipboard
fun showSeekButton(show: Boolean): ArcMediaPlayer

Configuration setting: This can also be set using .configureMediaPlayer and the ArcXPVideoConfig object. Show or hide the seek buttons on the control bar.

Link copied to clipboard
fun start()

Programmatically start the player

Link copied to clipboard
fun stop()

Programmatically stop the player

Link copied to clipboard
fun toggleAutoShow(show: Boolean)

Programmatically toggles controller auto show, if true will use config values used to disable controls during pip

Link copied to clipboard
fun toggleClosedCaption(show: Boolean): Boolean

Programmatically toggle the closed captioning on or off

Link copied to clipboard
fun trackErrors(listener: ArcVideoSDKErrorListener?): ArcMediaPlayer

Used to track errors being returned.

Link copied to clipboard
fun trackMediaEvents(listener: ArcVideoEventsListener): ArcMediaPlayer

Used to track the various media events being returned.

Link copied to clipboard
fun useDialogForFullscreen(use: Boolean): ArcMediaPlayer

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.

Properties

Link copied to clipboard
val currentTimelinePosition: Long

Returns the current position within the timeline for live video feeds.

Link copied to clipboard
val currentVideoDuration: Long

Returns the duration of the video

Link copied to clipboard
val isClosedCaptionAvailable: Boolean

Returns if closed caption is available on the currently playing video.

Link copied to clipboard
val isControlsVisible: Boolean

Returns if the control bar is currently showing on the media player.

Link copied to clipboard
val isFullScreen: Boolean

Returns if the video is currently playing in full screen

Link copied to clipboard
val playbackState: Int

Returns the current playback state

Link copied to clipboard
val playerPosition: Long

Returns the current position in milliseconds of the video. Used for VOD videos

Link copied to clipboard
val playWhenReadyState: Boolean

Returns the play when ready state of the player

Link copied to clipboard
val sdkVersion: String

Returns the current SDK version