Android SDK Version
  • java.lang.Object
    • FrameLayout
      • com.facebook.ads.internal.api.AdComponentView
        • com.facebook.ads.MediaViewVideoRenderer

public abstract class MediaViewVideoRenderer
extends com.facebook.ads.internal.api.AdComponentView
Abstract video renderer class that developers can extend to implement very customized video UI within the MediaView.
Since:
4.28
Field Summary
Modifier and TypeField and Description
protected NativeAdnativeAd
Deprecated. 
protected VideoAutoplayBehaviorvideoAutoplayBehavior
Deprecated. 
Constructor Summary
Constructor and Description
MediaViewVideoRenderer(Context context) 
MediaViewVideoRenderer(Context context, AttributeSet attrs) 
MediaViewVideoRenderer(Context context, AttributeSet attrs, int defStyleAttr) 
MediaViewVideoRenderer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) 
Method Summary
Modifier and TypeMethod and Description
voidaddView(View child) 
voidaddView(View child, int index) 
voidaddView(View child, int width, int height) 
voidaddView(View child, int index, ViewGroup.LayoutParams params) 
voidaddView(View child, ViewGroup.LayoutParams params) 
voiddestroy()
Deprecated. 
voiddisengageSeek(VideoStartReason startReason)
Take the video out of seek mode.
voidengageSeek()
Used to put the video into seek mode.
intgetCurrentTimeMs()
Get the current playback position in milliseconds.
intgetDuration()
Get the duration of the video in milliseconds.
com.facebook.ads.internal.api.MediaViewVideoRendererApigetMediaViewVideoRendererApi()
Used by other SDK classes and subject to change.
floatgetVolume()
Get the volume of the video player.
voidonCompleted()
Callback when the video has completed playing.
voidonError()
Callback when the video had an error during initialization or playback.
voidonPaused()
Callback when the video has been paused.
voidonPlayed()
Callback when the video has started playing.
voidonPrepared()
Callback when the video is prepared and ready to play.
voidonSeek()
Callback when the video is seeked.
voidonSeekDisengaged()
Callback when seek mode is disengaged.
voidonSeekEngaged()
Callback when seek mode is engaged.
voidonVolumeChanged()
Callback when the volume of the video has changed.
voidpause(boolean pausedByUser)
Stop video playback.
voidplay(VideoStartReason startReason)
Start video playback.
voidseekTo(int timeMs)
Set the seek position in milliseconds.
voidsetNativeAd(NativeAd nativeAd)
Deprecated. 
since 5.2
voidsetVolume(float volume)
Set the volume of the video player.
booleanshouldAllowBackgroundPlayback()
Whether background video playback should be enabled or not.
booleanshouldAutoplay()
Returns if the video should autoplay or not.
voidunsetNativeAd()
Deprecated. 
since 5.2
Methods inherited from class com.facebook.ads.internal.api.AdComponentView
attachAdComponentViewApi, onAttachedToWindow, onDetachedFromWindow, onMeasure, onVisibilityChanged, onWindowFocusChanged, setLayoutParams
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail

nativeAd

@Deprecated
protected NativeAd nativeAd
Deprecated. 

videoAutoplayBehavior

@Deprecated
protected VideoAutoplayBehavior videoAutoplayBehavior
Deprecated. 
Constructor Detail

MediaViewVideoRenderer

public MediaViewVideoRenderer(Context context)

MediaViewVideoRenderer

public MediaViewVideoRenderer(Context context,
                              AttributeSet attrs)

MediaViewVideoRenderer

public MediaViewVideoRenderer(Context context,
                              AttributeSet attrs,
                              int defStyleAttr)

MediaViewVideoRenderer

public MediaViewVideoRenderer(Context context,
                              AttributeSet attrs,
                              int defStyleAttr,
                              int defStyleRes)
Method Detail

getMediaViewVideoRendererApi

public com.facebook.ads.internal.api.MediaViewVideoRendererApi getMediaViewVideoRendererApi()
Used by other SDK classes and subject to change.

setNativeAd

@Deprecated
public void setNativeAd(NativeAd nativeAd)
Deprecated. since 5.2
Load the MediaView with a NativeAd.
Parameters:
nativeAd - NativeAd to load
Since:
4.28

unsetNativeAd

@Deprecated
public void unsetNativeAd()
Deprecated. since 5.2
Unload the MediaView. It is possible to reuse the same MediaView with different NativeAd objects to avoid unnecessary inflation steps.
Since:
4.28

play

public final void play(VideoStartReason startReason)
Start video playback.
Parameters:
startReason - Whether this video play was triggered by user or an automatic mechanism.
Since:
4.28

pause

public final void pause(boolean pausedByUser)
Stop video playback.
Since:
4.28

getCurrentTimeMs

public final int getCurrentTimeMs()
Get the current playback position in milliseconds.
Returns:
int value representing current playback position in milliseconds.
Since:
4.28

engageSeek

public final void engageSeek()
Used to put the video into seek mode. Video playback halts, and one or more calls to seekTo can be made before calling disengageVideoSeek.
Since:
4.28

disengageSeek

public final void disengageSeek(VideoStartReason startReason)
Take the video out of seek mode.
Parameters:
startReason - Playback may resume after disengaging seek and we need to know whether this was triggered by user or an automatic mechanism for proper watch time attribution.
Since:
4.28

seekTo

public final void seekTo(int timeMs)
Set the seek position in milliseconds. Only works after calling engageSeek.
Parameters:
timeMs - int value representing the position in milliseconds
Since:
4.28

getDuration

public final int getDuration()
Get the duration of the video in milliseconds.
Returns:
int value representing the duration of the video in milliseconds.
Since:
4.28

setVolume

public final void setVolume(float volume)
Set the volume of the video player.
Parameters:
volume - float value representing the volume
Since:
4.28

getVolume

public final float getVolume()
Get the volume of the video player.
Returns:
float value representing the volume
Since:
4.28

shouldAutoplay

public final boolean shouldAutoplay()
Returns if the video should autoplay or not. This SDK will determine whether autoplay should happen based on placement settings.
Returns:
true if this video should be autoplayed

destroy

@Deprecated
public void destroy()
Deprecated. 

onPrepared

public void onPrepared()
Callback when the video is prepared and ready to play.
Since:
4.28

onPlayed

public void onPlayed()
Callback when the video has started playing.
Since:
4.28

onPaused

public void onPaused()
Callback when the video has been paused.
Since:
4.28

onSeekEngaged

public void onSeekEngaged()
Callback when seek mode is engaged.
Since:
4.28

onSeek

public void onSeek()
Callback when the video is seeked.
Since:
4.28

onSeekDisengaged

public void onSeekDisengaged()
Callback when seek mode is disengaged.
Since:
4.28

onCompleted

public void onCompleted()
Callback when the video has completed playing.
Since:
4.28

onVolumeChanged

public void onVolumeChanged()
Callback when the volume of the video has changed.
Since:
4.28

onError

public void onError()
Callback when the video had an error during initialization or playback.
Since:
4.28

shouldAllowBackgroundPlayback

public boolean shouldAllowBackgroundPlayback()
Whether background video playback should be enabled or not. This will allow videos in Native Ads to keep playing sound when the video is off-screen. It will not work when the video is set to full screen mode. Override this and return true to enable background playback.
Returns:
true if background video playback is enabled, false otherwise
Since:
4.28

addView

public void addView(View child)

addView

public void addView(View child,
                    int index)

addView

public void addView(View child,
                    ViewGroup.LayoutParams params)

addView

public void addView(View child,
                    int width,
                    int height)

addView

public void addView(View child,
                    int index,
                    ViewGroup.LayoutParams params)