nexxPLAY needs a single view. The root view is the view group where the media player control layout (the player skin) is shown. Also the player needs the Acitivity's window
importtv.nexx.android.play.NexxPLAY;importtv.nexx.android.play.NexxPLAYConfiguration;importtv.nexx.android.play.NexxPLAYEnvironment;publicclassPlayerActivity{privateNexxPLAY player; @OverridepublicvoidonCreate(Bundle savedInstanceState) {...ViewGroup root = (ViewGroup) findViewById(R.id.root);//define the Player objectNexxPLAY player =newNexxPLAY(this, root, getWindow());//define an Environment and specify at least the DomainIDNexxPLAYEnvironment env =newNexxPLAYEnvironment(newHashMap<String,Object>() {{ put(domain,":domainid");... }});player.setEnvironment(env);//define a Configuration and specify all Overrides, that shall be appliedNexxPLAYConfiguration config =newNexxPLAYConfiguration(newHashMap<String,Object>() {{... }});//start Playback of a given Media (here, by Streamtype and ID)player.startPlay(":streamtype",":mediaid", config); } @OverridepublicvoidonResume() { super.onResume();player.onActivityResume(); } @OverridepublicvoidonPause() { super.onPause();player.onActivityPause(); } @OverridepublicvoidonDestroy() { super.onDestroy();player.onActivityDestroyed(); }}
You can also use the NexxPlayProvider Singleton, if you prefer a synchronized Singleton Approach:
@OverridepublicvoidonCreate(Bundle savedInstanceState) {...NexxPLAY player =NexxPlayProvider.init(getContext(), root,getActivity().getWindow());...}
Player Environment
The NexxPLAYEnvironment object contains global settings for the player object. Except for the domain all the settings are optional and have a predefined value. The settings are:
On TV, the Player will always start in Fullscreen (unless its Audio and respectViewSizeForAudio is set to 1). Therefore, "alwaysInFullscreen" and "showCloseButtonOnFullscreen" have no Effect.
Player Configuration
Just like the Javascript Player, the Player can be configured by a Configuration Object. This Object will be used in one of the various play() Methods of the SDK.
All Options are identical to the general SDK Override Options, you will find here:
Please notice, that some Options only make sense in the Web and are therefore not supported.
In case of "starting the Player muted", please notice the special Overrides for native Players on the same link.
If you are looking for the TCF Consent String Management, this is documented here:
Public Methods
Preparing and Configuring the Player
//Sets the environment object for the player. This method must be called before any start method is calledsetEnvironment(NexxPLAYEnvironment nexxPLAYEnvironment)
//update a previously defined Environment Value//domain, language, sessionID and alwaysInFullscreen cannot be updatedupdateEnvironment(String key, String value)
//start the Player with the given MediastartPlay(String streamtype,String mediaID,NexxPLAYConfiguration configuration)
//start the Player with a given GlobalIDstartPlayWithGlobalID(String globalID, NexxPLAYConfiguration configuration)
//start the Player with a Remote Media ReferencestartPlayWithRemoteMedia(String streamtype, String reference, String provider, NexxPLAYConfiguration configuration)
//update a previously defined Configuration. //supported are currently only the ad*URL Configuration Settings (and webURLRepresentation).updateConfiguration(String key, String value)
//will clear all currently cached DataclearCache()
Playback Control
//restart a paused Playerplay()
//pauses a playing Playerpause()
//pauses/restarts a Player, depending on its current Statetoggle()
//mutes the Playermute()
//unmutes the Playerunmute()
//seeks to the given Time, if the Media supports thatseekTo(Float time)
//seeks relatively by a certain amount of Seconds, if the Media supports thatseekBy(Float seconds)
//swap to the next Item in a Container Elementnext()
//swap to the previous Item in a Container Elementprevious()
//swap to a new Item in a Container ElementswapToPosition(int position)
//swap to a completely new Media ItemswapToMediaItem(String mediaID, String streamtype:String, int startPosition = 0, Double delay = 0, String reason = "", Boolean showReturnButton = false)
//swap to a completely new Media Item, referenced by a GlobalIDswapToGlobalID(String globalID, int startPosition = 0, Double delay = 0, String reason = "", Boolean showReturnButton = false)
//swap to a completely new Media Item, referenced by a Remote ReferenceswapToRemoteMedia(String reference, String streamtype, String provider, Double delay = 0, String reason:String = "", Boolean showReturnButton = false)
Requesting Player Status and Details
//returns Information about the currently played Media ItemgetCurrentMedia(): tv.nexx.play.android.MediaData
//returns Information about the Container Element of the currently played Media ItemgetCurrentMediaParent():tv.nexx.play.android.MediaParentData
//returns Information about the current Playback State of the PlayergetCurrentPlaybackState():tv.nexx.play.android.PlaybackState
//returns the Captions of the current Media Item (or only the ones matching the given Language)getTextTracks(): tv.nexx.play.android.TextTrack[]
//returns all available Audio Tracks of the current MediagetAudioTracks(): tv.nexx.play.android.AudioTrack[]
//returns the current playback time of the PlayergetCurrentTime():Float
//returns the Files, connected to the current MediagetConnectedFiles():tv.nexx.play.android.ConnectedFile[]
//returns true, if the Player is currently playingisPlaying(): Boolean
//returns true, if the Player is currently playing an AdisPlayingAd(): Boolean
//returns true, if the Player is currently mutedisMuted(): Boolean
//returns true, if the Player is currently in PictureToPicture ModeisInPiP(): Boolean
//returns true, if the Player is currently castingisCasting():Boolean
LocalMedia and Offline Playback
nexxPLAY for android also supports Playback of previously downloaded Media Items and therefore offers some SDK Methods to manage localMedia.
//start a Download of a given Media Item (internal ID or Remote Reference)startDownloadLocalMedia(String mediaID, String streamtype, @NullableString provider)
//returns a List of currently available localMedia ItemslistLocalMedia(@NullableString streamtype)
//returns true, if the referenced Media Item is already available locallyhasDownloadOfLocalMedia(String mediaID, String streamtype, @NullableString provider): Boolean
//remove a previously downloaded Media ItemremoveLocalMedia(String mediaID:String, String streamtype, @NullableString provider:String)
//remove all previously downloaded Media ItemsclearLocalMedia(@NullableString streamtype)
//returns the currently used Storage by downloaded Media ItemsdiskSpaceUsedForLocalMedia():long
This Feature must be enabled within nexxOMNA. Furthermore, various Settings to finetune the Details of the localMedia Behaviour can be setup there. Contact 3Q for more Information.
Player Notifications
Just like the Javascript Player, the Player emits all Events to a Listener Function, that can be configured as outlined below. The Player Class has to implement the NexxPLAYNotification.Listener Interface in this case.
nexxPLAY supports Video Ads on all Platforms. This is handled internally with the Google IMA Framework. To minimize the Google Footprint in the Android Manifests, nexxPLAY seperates the Ad Functionality from the main SDK since Version 6.3.00.
To support Ads, just add a Reference to the latest AdManager SDK and add a Reference to the Player Environment like the following:
importtv.nexx.android.play.NexxPLAY;importtv.nexx.android.play.NexxPLAYEnvironment;publicclassPlayerActivity{ @OverridepublicvoidonCreate(Bundle savedInstanceState) {...//define the Player objectNexxPLAY player =newNexxPLAY(this, root, getWindow());//define an Environment and specify at least the DomainIDNexxPLAYEnvironment env =newNexxPLAYEnvironment(newHashMap<String,Object>() {{ put(domain,":domainid"); put(adManager,new NexxPLAYAdManager(PlayerActivity.this))... }});player.setEnvironment(env);... }
TV Support
Remote Control
nexxPLAY for android works identical on mobile Devices as on Phones - unless the Platform demands different Behaviour. Most significantly, you must support Remote Control Input and forward it to the Player:
As it is common on TV to show the Player in Fullscreen, the Overrides "alwaysInFullscreen" and "showCloseButtonOnFullscreen" are ignored on this Platform.
In case the Player will use Audio Contents on TV, it might make sense to not use it Fullscreen. Use the Configuration Option "respectViewSizeForAudio" in this Case.
Homescreen Rows
nexxPLAY for Android TV also support the "WatchNext" System, if possible (GoogleTV needs a manual Review for this Feature).
In order to make this work, a valid contentURITemplate and contentIDTemplate must be set. This can be done either within nexxOMNIA or via the Environment Settings.
Please notice, that nexxOMNIA can also manage the Channel Rows on androidTV. For this, you must also add the "Channel Widget" to your Project (see below).
Picture-in-Picture
To enable Picture-in-Picture (on mobile, Tablet and/or TV) add the following code:
Picture-in-Picture must also be declared in the App Manifest, at least like this:
android:supportsPictureInPicture="true"
Picture-in-Picture also requires to be enabled in nexxOMNIA Player Settings and/or Configuration with Overrides.
Additionally, it may not be available on all Devices, depending on Hardware Capabilities.
Chromecast
nexxPLAY for android supports Chromecast and Casting on mobile and Tablet Devices.
Chromecast can only be used, if 3Q adds this Module to the target Domain. If Chromecast Module is enabled, follow these Implementation Steps to enable Chromecast also in the android App.
First, add the Chromecast Receiver Application ID (from 3Q) to your "res/values/strings.xml":
Within the main Application, as early as possible and in the "onCreate" Method, initiate the CastContext, provided by Google Play Services and save it. This CastContext should be used then every time, nexxPLAY is initiated.
publicclassMainActivity{... @OverridepublicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);CastContext.getSharedInstance(this,Executors.newSingleThreadExecutor()).addOnSuccessListener(castContext -> { mCastContext=castContext; }).addOnFailureListener(exception -> {//some Devices (especially TVs etc) may not support Casting }); }...}
Every time, the Application starts a new nexxPLAY Instance, set NexxPLAYEnvironment.castContext to the captured CastContext (mCastContext in this Example). The rest will be handled by nexxPLAY internally.
Global MediaSession
normally, there is no need to handle MediaSession and TransportControl app-wise, as nexxPLAY will handle this automatically and initiate/terminate the necessary Objects and States corresponding to Config and System Capabilities.
If your App needs a consistent MediaSession though (for example for Assistant Commands), you can use the Environment Options mediaSession and send your Global MediaSession to the Player, whenever it is initiated. In this case, the Player will NOT terminate the Session, even if it will be destroyed. Nevertheless, as the Player changes the Callbacks of the MediaSession, your App might have to set the App-related Callbacks later.
In case nexxPLAY received an app-related Command via MediaSession while active, the App will be informed about that via the nexxPLAY Event System.
Notch and Display CutOut
nexxPLAY will automatically respect the App Notch Settings and expand under it, if defined. If this is desired, configure the App Theme like: