public class APSMediaPlayer extends KRHub implements VolumeChangedInterface, APSMediaEventStateListener, APSMediaEventTimeoutListener
| Modifier and Type | Class and Description |
|---|---|
static class |
APSMediaPlayer.FullscreenOrientationBehaviour |
static class |
APSMediaPlayer.MPMovieFinishReason |
static class |
APSMediaPlayer.MPMoviePlaybackState |
| Modifier and Type | Field and Description |
|---|---|
APSMediaUnit |
_currentUnit |
static java.lang.String |
APSMoviePlayerControlsDisplayedNotification
Posted when the video controls bar becomes visible
|
static java.lang.String |
APSMoviePlayerControlsHiddenNotification
Posted when the video controls bar becomes hidden
|
static java.lang.String |
APSMoviePlayerStatusChangedNotification
Posted when the media player playback state has changed.
|
static java.lang.String |
APSMoviePlayerWasTappedNotification
Posted when the user taps on the media player surface
|
HandlerThread |
handlerThread |
static java.lang.String |
kAPSMediaPlayerDRMPluginsGroup |
static java.lang.String |
kAPSMediaPlayerFrameworkExtensionsGroup |
static java.lang.String |
kAPSMediaPlayerOverlayControllersGroup
The group name that overlay controllers must use when registering with the player.
|
kKRDefaultAdapterGroup| Modifier and Type | Method and Description |
|---|---|
void |
addOverlays(java.util.ArrayList<APSMediaOverlay> overlays)
Enqueues a series of overlays to be triggered in the current media unit.
|
void |
addTrackingEventListener(APSMediaPlayerTrackingEventListener listener)
Registers an event listener for receiving player events.
|
void |
back()
Proceeds to the previous unit in the playlist .
|
void |
computeSurfaceSize()
Recalculate the rendering surface size
|
APSMediaOverlay |
controlsOverlay()
Generates an APSMediaOverlay object for displaying the built-in controls on screen, based
on the settings of the unit.
|
int |
currentPlaybackTime()
Returns the current playback time.
|
APSMediaUnit |
currentUnit()
Returns a copy of the currently playing media unit.
|
int |
duration()
Returns the current unit's video clip total duration.
|
void |
emitEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
Bundle additionalInfo,
APSMediaEvent sourceEvent)
Sends an APSMediaTrackingEvent to all registered listeners
|
void |
enterFullscreen() |
void |
exitFullscreen()
Make the player exit full-screen mode
|
void |
finish()
Tears down all player resources, causing any currently playing units to stop and any
tracking events to be issued.
|
void |
fireClickTrackingBeacons()
Request the firing of the click tracking beacons in case a non-standard ad overlay is used
|
APSMediaPlayerActionDelegate |
getActionDelegate() |
Activity |
getActivity()
Returns a reference to the Activity the player was initialized with.
|
java.lang.String |
getAdvertisingIdentifier() |
java.lang.String |
getAdvertisingIdentifierType() |
long |
getCachedPlaybackTime() |
java.lang.String |
getCurrentPlayingUrl() |
Handler |
getHandler()
Returns a reference to a Handler for posting tasks to the UI thread.
|
okhttp3.OkHttpClient |
getHttpClient()
The Veeplay SDK uses OkHttp for sending tracking requests back to the VAST enabled
ad-servers.
|
HTTPErrorsListener |
getHttpErrorsListener() |
static APSMediaPlayer |
getInstance()
Returns the singleton
APSMediaPlayer instance, creating it if necessary. |
int |
getMainViewHeight() |
int |
getMainViewWidth() |
RelativeLayout |
getOverlayContainer() |
java.lang.String |
getPackageName() |
java.util.List<APSMediaEvent> |
getPlaylist() |
RegulationInformation |
getRegulationInformation() |
Size |
getSize() |
java.lang.String |
getUserAgent() |
Location |
getUserLocation() |
java.lang.String |
getYoutubeApiKey()
Getter for the YouTube API key, used by OverlayControllers to provide native YouTube integration
|
void |
hideControls() |
void |
hideHud()
Hides the player "loading" activity indicator.
|
void |
init(Activity activity,
boolean statusBarVisible)
Initialize the Veeplay SDK.
|
void |
insertMediaUnits(java.util.ArrayList<APSMediaUnit> mediaUnits)
Inserts new media units after the current one, in the current playlist.
|
boolean |
isAllowConditionalAds() |
boolean |
isCurrentlyInFullscreenOverlayActivity() |
boolean |
isFullscreen()
Returns a boolean value specifing if the player is currently in fullscreen (read-only).
|
boolean |
isGoogleCastEnabled()
Check if Google Cast support is enabled
|
static boolean |
isInitialized()
Checks if the player was already previously initialized
|
boolean |
isLeaveFullscreenOnStop() |
boolean |
isPaused() |
boolean |
isPlaying()
Returns a Boolean value specifing if the player is currently playing a playlist of units (read-only).
|
boolean |
isPreferExoPlayer2() |
boolean |
isPreferGoogleIma()
Check if the Google IMA SDK is enabled (replacing Veeplay VAST parser)
|
boolean |
isPreferMediaPlayerRenderer() |
boolean |
isProcessing()
Returns a Boolean value specifing if the player is currently rendering a playlist of units (read-only).
|
boolean |
isRestrictRootedAccess() |
boolean |
isSecureSurfaceView()
Check if the surface view is secured from capture
|
boolean |
isSeeking()
Method for checking if the player is currently doing a seek operation
|
boolean |
isStreamingUrl(java.lang.String url)
Method for determining if an URL represents a stream or not
|
boolean |
isViewable()
Checks if the Veeplay container is currently on-screen and un-obscured by any other views
|
void |
loadStatePlayable()
Once the active renderer has started playback,
this method handles the triggering of the correct tracking events,
as well as starting the internal state timer.
|
void |
log(java.lang.String message)
Posts a message to LogCat
|
boolean |
movieSourceTypeIsLiveStream() |
void |
next()
Proceeds to the next unit in the playlist and sends an exit event.
|
void |
notifySeekFinished()
Used by renderers to notify that they have completed a seek operation.
|
void |
onActivityPaused()
Signals that the bound activity has entered the "paused" state
|
void |
onActivityResumed()
Signals that the bound activity has entered the "resumed" state
|
void |
onEventStateChanged(APSMediaEvent event,
APSMediaEvent.APSMediaEventState newEventState)
A listener for the current state of the events in the current unit.
|
void |
onEventTimeout(APSMediaEvent event)
A handler for APSMediaEvents that timeout during their preloading
|
boolean |
openURL(java.lang.String url)
Instructs the player that a new URL needs to be interpreted and executed.
|
void |
orientationWillChange()
Signals to the player that the orientation of the device is changing
|
void |
pause()
Pauses playback of the current unit.
|
void |
performPostTapAction()
Call this method in the onActivityResult callback of the activity linked to the player.
|
void |
play()
Starts playback of the current unit.
|
int |
playableDuration(int duration)
Returns the current unit's video clip playable duration (the time interval that has already buffered and is ready for playback).
|
void |
playAlreadySetMediaUnits() |
APSMediaPlayer.MPMoviePlaybackState |
playbackState()
Returns the current unit's playback state.
|
void |
playbackStateChanged(APSMediaPlayer.MPMoviePlaybackState newState,
boolean track) |
void |
playbackStateChanged(APSMediaPlayer.MPMoviePlaybackState newState,
boolean track,
Bundle additionalInfo)
Method for transitioning the player between various
playback states (paused / playing / seeking, for example)
|
IVeeplayRenderer |
player()
All Veeplay renderers (MediaPlayer, ExoPlayer, GoogleCast or any custom renderer) implement
the common interface IVeeplayRenderer
|
void |
playerTapped()
Signals to that the player view was tapped (for example for hiding the on-screen controls)
|
void |
playMediaUnits(java.util.ArrayList<APSMediaEvent> mediaUnits)
Sets and begins playback of an array of media units.
|
void |
playVideo(java.lang.String url)
With a currently running content unit, start playback of another stream
|
void |
removeAllTrackingEventListeners()
Removes all currently registered listeners.
|
void |
removeMediaUnits(java.util.List<APSMediaEvent> units)
Removes a list of media units from the playlist
|
void |
removeTrackingEventListener(APSMediaPlayerTrackingEventListener listener)
Removes a registered event listener.
|
void |
replaceCurrentUnitWithUnits(java.util.ArrayList<APSMediaUnit> units)
Replaces the currently playing APSMediaUnit with a collection of media units.
|
void |
resetDisplayedOverlays()
Repositions all currently displayed overlays
|
void |
resumePlay()
Restarts playback
|
void |
seekTo(int pos)
Sets the current playback time.
|
void |
setActionDelegate(APSMediaPlayerActionDelegate actionDelegate) |
void |
setAdvancedViewabilityTracking(boolean isEnabled)
Enable more advanced viewability tracking that takes the entire hierarchy into account
|
void |
setAdvertisingIdentifier(java.lang.String advertisingIdentifier) |
void |
setAdvertisingIdentifierType(java.lang.String advertisingIdentifierType) |
void |
setAllowConditionalAds(boolean allowConditionalAds) |
void |
setAutoPauseWhenNotVisible(boolean isEnabled)
Automatically pause playback if the player container is not viewable
|
void |
setCurrentlyInFullscreenOverlayActivity(boolean currentlyInFullscreenOverlayActivity) |
void |
setFullscreenOrientationBehaviour(APSMediaPlayer.FullscreenOrientationBehaviour fullscreenOrientationBehaviour) |
void |
setGoogleCastEnabled()
Enable Google Cast Media Route Button in all content units automatically
|
void |
setHttpErrorsListener(HTTPErrorsListener httpErrorsListener) |
void |
setInlineModeParent(ViewGroup parent) |
void |
setLeaveFullscreenOnStop(boolean leaveFullscreenOnStop) |
void |
setMediaUnits(java.util.ArrayList<APSMediaEvent> mediaUnits)
Sets new units to the playlist, clearing any old ones.
|
void |
setMute(boolean toMute)
Mutes or unmutes audio playback.
|
void |
setPlayableDuration(int duration)
Method for setting the currently buffered duration
|
void |
setPlayExternalOverlaysFullscreen(boolean fullscreenMode) |
void |
setPreferExoPlayer2(boolean preferExoPlayer2) |
void |
setPreferGoogleIma(boolean preferGoogleIma)
Enable or disable Google IMA VAST parser support.
|
void |
setPreferMediaPlayerRenderer(boolean preferMediaPlayer) |
void |
setRegulationInformation(RegulationInformation regulationInformation) |
void |
setRestrictRootedAccess(boolean restrictRootedAccess) |
void |
setSecureSurfaceView(boolean is_secure)
Method for preventing the player SurfaceView from being captured in a screenshot or on
unsecure screens.
|
void |
setSize(int width,
int height)
Sets the size of the main player container.
|
void |
setUserAgent(java.lang.String newUserAgent) |
void |
setUserLocation(Location userLocation) |
void |
setVolume(float volume)
Set the current playback audio volume.
|
void |
setYouTubeApiKey(java.lang.String apiKey)
Method for setting the YouTube API key (useful only if there are any YouTubeOverlayControllers used).
|
boolean |
shouldAutoplay()
Checks if currentUnit is not null
|
void |
showControls() |
void |
showHud()
Shows the player "loading" activity indicator.
|
void |
skip()
Proceeds to the next unit in the playlist and sends a skip event.
|
void |
step()
Silently proceeds to the next unit in the playlist.
|
void |
stop()
Stops playback of the current unit.
|
void |
switchRenderer()
Method for switching the current renderer to the next highest priority rendererer.
|
void |
toggleFullscreen()
Toggle the current fullscreen status.
|
void |
trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent) |
void |
trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent,
boolean emitEvent) |
void |
trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent,
boolean emitEvent,
Bundle additionalInfo)
Sends tracking information to one or more servers.
|
void |
unitFinished(APSMediaPlayer.MPMovieFinishReason reason)
Handles the tear-down of the currently playing unit when it finishes (either because
of unit completion, or because an error has occured or the unit is being skipped).
|
void |
userPinched(float scale)
Handle a pinch action on the player view, toggling full screen mode on.
|
ViewGroup |
viewController()
The container
View of the player. |
void |
volumeChanged(int volume)
Detects changes in the current system audio volume and triggers any relevant VAST events.
|
adapterForType, adapterForTypeInGroup, adaptersForGroup, registerAdapter, registerAdapterInGroup, registerClass, registerClassInGrouppublic static final java.lang.String kAPSMediaPlayerOverlayControllersGroup
public static final java.lang.String kAPSMediaPlayerFrameworkExtensionsGroup
public static final java.lang.String kAPSMediaPlayerDRMPluginsGroup
public static final java.lang.String APSMoviePlayerWasTappedNotification
public static final java.lang.String APSMoviePlayerControlsDisplayedNotification
public static final java.lang.String APSMoviePlayerControlsHiddenNotification
public static final java.lang.String APSMoviePlayerStatusChangedNotification
playbackState method of the APSMediaPlayer instance.public APSMediaUnit _currentUnit
public final HandlerThread handlerThread
public boolean isProcessing()
public static APSMediaPlayer getInstance()
APSMediaPlayer instance, creating it if necessary.APSMediaPlayer instancepublic Activity getActivity()
public Handler getHandler()
public APSMediaOverlay controlsOverlay()
public void userPinched(float scale)
scale - the scale at which the pinch gesture was performedpublic boolean isFullscreen()
public void toggleFullscreen()
public void enterFullscreen()
public void setInlineModeParent(ViewGroup parent)
public void exitFullscreen()
public void init(Activity activity,
boolean statusBarVisible)
activity - the Activity the player is bound tostatusBarVisible - whether the height of the OS status bar should be taken into account
when layoutingpublic void playerTapped()
public void showControls()
public void hideControls()
public void log(java.lang.String message)
message - The message to be postedpublic void trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent)
public void trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent,
boolean emitEvent)
public void trackforEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
APSMediaEvent sourceEvent,
boolean emitEvent,
Bundle additionalInfo)
APSMediaTrackingEventsAPSMediaTrackingEvents for a list of supported event types.urls - An array of String objects that should be pinged.event - A descriptive text of the events.type - The tracked event type. See APSMediaTrackingEvents.sourceEvent - The APSMediaUnit or APSMediaOverlay that triggered this eventpublic java.lang.String getCurrentPlayingUrl()
public boolean shouldAutoplay()
public APSMediaUnit currentUnit()
APSMediaUnit object
representing the current unit.public boolean openURL(java.lang.String url)
url - The URL that needs to be loaded.public void performPostTapAction()
public void playMediaUnits(java.util.ArrayList<APSMediaEvent> mediaUnits)
mediaUnits - An array of APSMediaUnit objects.public void playAlreadySetMediaUnits()
public void setSize(int width,
int height)
width - in pixelsheight - in pixelspublic Size getSize()
public ViewGroup viewController()
View of the player.public IVeeplayRenderer player()
public void playbackStateChanged(APSMediaPlayer.MPMoviePlaybackState newState, boolean track)
public void playbackStateChanged(APSMediaPlayer.MPMoviePlaybackState newState, boolean track, Bundle additionalInfo)
newState - the new playback state the player is transitioning intotrack - whether to send tracking requests to relevant ad-servers or not.public APSMediaPlayer.MPMoviePlaybackState playbackState()
public void pause()
public void resumePlay()
public boolean isPaused()
public void play()
throws LicenseInvalidException,
RootedPhoneException
public void stop()
public int currentPlaybackTime()
public int playableDuration(int duration)
duration - - if the current video is shown through an overlay, this parameter will be multiplied by the result of the playableDuration method invoked on the overlay controller. Can be 0 in other cases;public void seekTo(int pos)
pos - The playback time to be set in ms.public int duration()
public boolean isPlaying()
public boolean movieSourceTypeIsLiveStream()
public void skip()
public void back()
public void loadStatePlayable()
public void unitFinished(APSMediaPlayer.MPMovieFinishReason reason)
reason - the reason the unit is being teared downpublic void volumeChanged(int volume)
volumeChanged in interface VolumeChangedInterfacevolume - the current audio volume valuepublic void finish()
public void next()
public void step()
public void resetDisplayedOverlays()
public void orientationWillChange()
public void showHud()
public void hideHud()
public boolean isStreamingUrl(java.lang.String url)
url - the url to be used for determinationpublic void setYouTubeApiKey(java.lang.String apiKey)
apiKey - - The Youtube API key obtained for the Google API Dashboardpublic java.lang.String getYoutubeApiKey()
public void addTrackingEventListener(APSMediaPlayerTrackingEventListener listener)
listener - - An instance of a class implementing the APSMediaPlayerTrackingEventListener interfacepublic void removeTrackingEventListener(APSMediaPlayerTrackingEventListener listener)
listener - - An instance of a class implementing the APSMediaPlayerTrackingEventListener interfacepublic void removeAllTrackingEventListeners()
public RelativeLayout getOverlayContainer()
public void emitEvent(java.util.ArrayList<java.lang.String> urls,
java.lang.String event,
APSMediaTrackingEvents.MediaEventType type,
Bundle additionalInfo,
APSMediaEvent sourceEvent)
urls - any associated tracking URLsevent - the VAST string name of the eventtype - the APSMediaTrackingEvent.MediaEventType value for the event to notifyadditionalInfo - a collection of additional information to relay (for example
the current playback time for a progress event)public void onEventStateChanged(APSMediaEvent event, APSMediaEvent.APSMediaEventState newEventState)
onEventStateChanged in interface APSMediaEventStateListenerevent - the event that has changed statenewEventState - the state the event has transitioned topublic void onEventTimeout(APSMediaEvent event)
onEventTimeout in interface APSMediaEventTimeoutListenerevent - the event that has encountered the timeoutpublic void replaceCurrentUnitWithUnits(java.util.ArrayList<APSMediaUnit> units)
units - an ArrayList of units to replace the current unit with.public void insertMediaUnits(java.util.ArrayList<APSMediaUnit> mediaUnits)
mediaUnits - An array of APSMediaUnit objects to be inserted into the playlist after the current unit.public void setMediaUnits(java.util.ArrayList<APSMediaEvent> mediaUnits)
mediaUnits - An array of APSMediaUnit objects to create a new playlist.public void addOverlays(java.util.ArrayList<APSMediaOverlay> overlays)
overlays - the overlays to be inserted into the queuepublic void setSecureSurfaceView(boolean is_secure)
is_secure - use true in order to secure the SurfaceViewpublic boolean isSecureSurfaceView()
public void setPlayableDuration(int duration)
duration - the currently playable durationpublic int getMainViewWidth()
public int getMainViewHeight()
public void playVideo(java.lang.String url)
url - the stream URLpublic void computeSurfaceSize()
public void onActivityPaused()
public void onActivityResumed()
public void switchRenderer()
public void setGoogleCastEnabled()
public boolean isGoogleCastEnabled()
public java.util.List<APSMediaEvent> getPlaylist()
public void removeMediaUnits(java.util.List<APSMediaEvent> units)
units - the list of units to be removedpublic void notifySeekFinished()
public boolean isSeeking()
public okhttp3.OkHttpClient getHttpClient()
public static boolean isInitialized()
public void setMute(boolean toMute)
toMute - - true for muting audio, false for unmutepublic void setVolume(float volume)
volume - - a float between 0f and 1fpublic void setFullscreenOrientationBehaviour(APSMediaPlayer.FullscreenOrientationBehaviour fullscreenOrientationBehaviour)
public boolean isViewable()
public long getCachedPlaybackTime()
public boolean isCurrentlyInFullscreenOverlayActivity()
public void setCurrentlyInFullscreenOverlayActivity(boolean currentlyInFullscreenOverlayActivity)
public void setUserAgent(java.lang.String newUserAgent)
public java.lang.String getUserAgent()
public APSMediaPlayerActionDelegate getActionDelegate()
public void setActionDelegate(APSMediaPlayerActionDelegate actionDelegate)
public boolean isPreferMediaPlayerRenderer()
public void setPreferMediaPlayerRenderer(boolean preferMediaPlayer)
public boolean isRestrictRootedAccess()
public void setRestrictRootedAccess(boolean restrictRootedAccess)
public boolean isPreferExoPlayer2()
public void setPreferExoPlayer2(boolean preferExoPlayer2)
public Location getUserLocation()
public void setUserLocation(Location userLocation)
public java.lang.String getAdvertisingIdentifier()
public void setAdvertisingIdentifier(java.lang.String advertisingIdentifier)
public java.lang.String getAdvertisingIdentifierType()
public void setAdvertisingIdentifierType(java.lang.String advertisingIdentifierType)
public RegulationInformation getRegulationInformation()
public void setRegulationInformation(RegulationInformation regulationInformation)
public java.lang.String getPackageName()
public boolean isAllowConditionalAds()
public void setAllowConditionalAds(boolean allowConditionalAds)
public HTTPErrorsListener getHttpErrorsListener()
public void setHttpErrorsListener(HTTPErrorsListener httpErrorsListener)
public boolean isLeaveFullscreenOnStop()
public void setLeaveFullscreenOnStop(boolean leaveFullscreenOnStop)
public void setPlayExternalOverlaysFullscreen(boolean fullscreenMode)
public boolean isPreferGoogleIma()
public void setPreferGoogleIma(boolean preferGoogleIma)
preferGoogleIma - true if Google IMA should be used, false for Veeplay VAST parserpublic void fireClickTrackingBeacons()
public void setAdvancedViewabilityTracking(boolean isEnabled)
isEnabled - - true if the advanced mode should be enabled, false otherwisepublic void setAutoPauseWhenNotVisible(boolean isEnabled)
isEnabled - - true if auto-pause should be enabled, false otherwise