Set up Android set-up-android
Learn how to set up the Streaming Media Collection Add-on for Android devices.
Prerequisites
-
Obtain valid configuration parameters for the Media SDK
These parameters can be obtained from an Adobe representative after you set up your analytics account. -
Implement ADBMobile for Android in your application
For more information about the Adobe Mobile SDK documentation, see Android SDK 4.x for Experience Cloud Solutions. -
Provide the following capabilities in your media player:
- An API to subscribe to player events - The Media SDK requires that you call a set of simple APIs when events occur in your player.
- An API that provides player information - This information includes details such as the media name and the play head position.
SDK Implementation
-
Add your downloaded Media SDK to your project.
-
Expand the Android zip file (e.g.,
MediaSDK-android-v2.*.zip
). -
Verify that the
MediaSDK.jar
file exists in thelibs/
directory. -
Add the library to your project.
IntelliJ IDEA:
-
Right click your project in the Project navigation panel.
-
Select Open Module Settings.
-
Under Project Settings, select Libraries.
-
Click + to add a new library.
-
Select Java and navigate to the
MediaSDK.jar
file. -
Select the modules in which you plan to use the mobile library.
-
Click Apply and then OK to close the Module Settings window.
Eclipse:
-
In the Eclipse IDE, right-click on the project name.
-
Click Build Path > Add External Archives .
-
Select
MediaSDK.jar
. -
Click Open.
-
Right-click the project again, and click Build Path > Configure Build Path .
-
Click the Order and Export tabs.
-
Ensure that the
MediaSDK.jar
file is selected.
-
-
-
Import the library.
code language-java import com.adobe.primetime.va.simple.MediaHeartbeat; import com.adobe.primetime.va.simple.MediaHeartbeat.MediaHeartbeatDelegate; import com.adobe.primetime.va.simple.MediaHeartbeatConfig; import com.adobe.primetime.va.simple.MediaObject;
-
Create the
MediaHeartbeatConfig
instance.Here is a sample
MediaHeartbeatConfig
initialization:code language-java // Media Heartbeat Initialization config.trackingServer = _<SAMPLE_HEARTBEAT_TRACKING_SERVER>_; config.channel = <SAMPLE_HEARTBEAT_CHANNEL>; config.appVersion = <SAMPLE_HEARTBEAT_SDK_VERSION>; config.ovp = <SAMPLE_HEARTBEAT_OVP_NAME>; config.playerName = <SAMPLE_PLAYER_NAME>; config.ssl = <true/false>; config.debugLogging = <true/false>;
-
Implement the
MediaHeartbeatDelegate
interface.code language-java public class VideoAnalyticsProvider implements Observer, MediaHeartbeatDelegate{}
code language-java // Replace <bitrate>, <startupTime>, <fps>, and // <droppeFrames> with the current playback QoS values. @Override public MediaObject getQoSObject() { return MediaHeartbeat.createQoSObject(<bitrate>, <startupTime>, <fps>, <droppedFrames>); } //Replace <currentPlaybackTime> with the video player current playback time @Override public Double getCurrentPlaybackTime() { return <currentPlaybackTime>; }
-
Create the
MediaHeartbeat
instance.Use the
MediaHeartbeatConfig
instance and theMediaHertbeatDelegate
instance to create theMediaHeartbeat
instance.code language-java // Replace <MediaHertbeatDelegate> with your delegate instance MediaHeartbeat _heartbeat = new MediaHeartbeat(<MediaHeartbeatDelegate>, config);
note important IMPORTANT Make sure that your MediaHeartbeat
instance is accessible and does not get deallocated until the end of the session. This instance will be used for all of the following tracking events.
Adding app permissions
Your app using the Media SDK requires the following permissions to send data in tracking calls:
INTERNET
ACCESS_NETWORK_STATE
To add these permissions, add the following lines to your AndroidManifest.xml
file in the application project directory:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Migrating from version 1.x to 2.x in Android
In versions 2.x, all of the public methods are consolidated into the com.adobe.primetime.va.simple.MediaHeartbeat
class to make it easier on developers. Also, all configs are now consolidated into the com.adobe.primetime.va.simple.MediaHeartbeatConfig
class.
For information about migrating from 1.x to 2.x, see the Legacy Implementation documentation.