Introduction
In this article, you will be provided with a step-by-step guide to building a video player with the Apollo SDK. Please visit Enable Enterprise customer development page to obtain the Apollo SDK file. With the SDK file, you can import the included AAR and AIDL library files to build your own video player.
Prerequisites
Android Studio: An IDE for Android app development.
Amino Media Player Device: The developed app can be run on any Amino Media Player device.
Apollo SDK File: The SDK file can be downloaded from Enable Enterprise customer development page
Summary
You are advised to install the latest version of Android Studio. The latest version of Android Studio will always provide you with the most up-to-date Android SDK resources, minimizing version dependencies when compiling your application.
Create A new Android Project
To create a test application for the Amino Media Player, select "Television" with "No Activity." A default project will be created by Android Studio without any activity or user interface. Design the user interface of the main activity to present a sample player in your application.
Select the Android version that matches your Amino Media Player version. Your test application needs a minimum Android SDK version that is lower than or equal to the Android version of your Amino Media Player. Select Language : Java , Build configuration Language : Groovy DSL ( build.gradle )
Import AAR player library
To run your sample application with the Amino SDK player, you need to import the player-related AAR (Android Archive Repository) library files into your Android Studio application project. Select the "Project" view in Android Studio. Create a "libs" directory under the root directory of your project.
Select "Open In" then "Explorer" to open the directory for the libs folder
Copy and paste the playerwrapper and analyticslib AAR library files into the libs directory of your application project.
Configure Build Gradle file
Your application needs to know where and which library files need to be implemented. The configurations are written in the build.gradle file of your app module under the Gradle Scripts section of Android Studio. Specify the location of the AAR file to include it, which is defined under the dependencies section of the build.gradle file.
Follow the steps below to edit the build.gradle file of the app module :
1. Switch back to Android view of Android Studio , the build.gradle is located at the gradle Scripts section
2. Edit the build.gradle file , add implementation file location for the AAR library files .
( Note that you will need to include other dependency to compile your code , please refer to the sample android studio project )
Create a player view to play the Video
Create a layout xml file for your application . On Android View , right click the folder "res" , select New and then "Android Resource File"
Select Resource type as "Layout" . Create a file name for your layout file .
Select the activity_main.xml under the newly created layout folder. Change to code view by pressing the icon at the top right corner .
Below is an example to create a StyledPlayerView for Exoplayer which is defined in activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_shuffle_button="true"
app:show_subtitle_button="true"
app:resize_mode="fit"
app:show_buffering="when_playing" />
</LinearLayout>
Create a theme style for your application
Create a style xml file to definite the theme for your application . On Android View , right click the folder "res" , select New and then "Android Resource File"
Below is an example for style.xml for which is using Theme.AppCompat as the application theme
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="TrackSelectionDialogThemeOverlay" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="windowNoTitle">false</item>
</style>
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@android:color/black</item>
</style>
</resources>
Create static string for your application project
Create a strings xml file to definite the theme for your application . On Android View , right click the folder "res" , select New and then "Android Resource File"
Below is an example for strings.xml, defines a static string for app_name .
<resources>
<string name="app_name">player</string>
</resources>
Create a java class to program the player ( Exoplayer )
Create a java class for your main activity . Right click your project folder under java . Select New , Java Class .
Put a name for your application activity for Exoplayer. As an example, a new Java Class "MainActivity" was created .
Here is an example of MainActivity . The program initializes an ExoPlayer instance, sets it to a StyledPlayerView, and prepares to play media from a specified multicast URL. The player is built in the initializePlayer method and configured during the onCreate lifecycle call.
package tv.amino.test.player;
import android.net.Uri;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.aminocom.mediaplayer.PlayerConfiguration;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.ui.StyledPlayerView;
public class MainActivity extends AppCompatActivity {
private ExoPlayer player;
private StyledPlayerView playerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PlayerConfiguration.setCustomConfig(this, null); //Initialize Player Configuration first
playerView = findViewById(R.id.player_view);
initializePlayer();
}
private void initializePlayer() {
player = new ExoPlayer.Builder(this).build();
playerView.setPlayer(player);
// Replace with your multicast stream URL
String multicastUrl = "udp://@233.22.133.11:8110"; // Example multicast address
MediaItem mediaItem = MediaItem.fromUri(Uri.parse(multicastUrl));
player.setMediaItem(mediaItem);
player.prepare();
player.play();
}
@Override
protected void onStop() {
super.onStop();
if (player != null) {
player.release();
player = null;
}
}
}
Application permission
Make sure you have defined internet and access_network_state as the permission for your application . Check the following line on the androidMainfest.xml file .
Build and test your Application
1. ADB connect your workstation to your Amino Media Player.
Download the android adb tool from :
https://developer.android.com/tools/releases/platform-tools
On your command terminal run : adb,exe connect <ip>
Alternative if you have a USB-A to USB-A cable , you can connect your workstation to the Amino Media Player with USB cable.
a) Connect the USB port next to the HDMI port
b) Enable "USB debugging" under Developer options of the setting menu
c) Reboot the Amino Media Player
d) The device will show up at "device Manager" page of the android studio automatically
2. Select the device to build and test run your application.
3. Press the "PLAY" button to process the test build.
4. Once the test build success , the studio will launch your test APP on Amino Media Player .
Sample Program
A sample android studio project zip can be downloaded here
and follow the steps below to import the project .
1. Unzip the zip file
2. File -> New -> Import Project
3. Select the gradle file and import the project to your android studio