See: Description
The Veeplay Media Player allows you to:
repositories {
mavenCentral()
maven {
url "https://s3-eu-west-1.amazonaws.com/android.veeplay.com/releases"
}
}
dependencies {
implementation 'com.veeplay:veeplay-player-android:3.1.21'
}
import com.appscend.media.APSMediaBuilder;
import com.appscend.media.APSMediaPlayer;
Create a new APSMediaBuilder instance and configure it from remote JSON:
APSMediaBuilder builder = new APSMediaBuilder();
try {
builder.configureFromURL(new
URL("http://domain.tld/player.json"));
}
catch (MalformedURLException e) {
e.printStackTrace();
}
Optionally, set the debugMode flag to true to enable logCat logging:
builder.debugMode=true;
Create a new APSMediaPlayer instance and set the size of the video player:
APSMediaPlayer.getInstance().init(this, false);
APSMediaPlayer.getInstance().setYouTubeApiKey("YOUR_API_KEY"); // optional, for YouTube integration usage.
APSMediaPlayer.getInstance().setSize(720, 1280);
Add the media player to a layout and add the layout to the current Activity:
RelativeLayout layout = new RelativeLayout(this);
layout.setBackgroundColor(Color.WHITE);
layout.addView(APSMediaPlayer.getInstance().viewController());
setContentView(layout);
Play content as configured:
APSMediaPlayer.getInstance().playMediaUnits(builder.mediaUnits());
You will also probably want to link activity events (onPause, onResume) to player
events. The below examples will pause and start the player when existing, entering the
activity and will cancel the current running units list when the back button is pressed.
@Override
protected void onPause() {
super.onPause();
APSMediaPlayer.getInstance().pause();
}
@Override
protected void onResume() {
super.onResume();
APSMediaPlayer.getInstance().resumePlay();
}
@Override
public void onBackPressed() {
super.onBackPressed();
APSMediaPlayer.getInstance().finish();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
APSMediaPlayer.getInstance().computeSurfaceSize();
APSMediaPlayer.getInstance().orientationWillChange();
}
Finally, add the correct permissions to your Android Manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.hardware.screen.landscape" android:required="false" />
And also, declare a new activity that will be called for clickthroughs:
<activity
android:name="com.appscend.utilities.WebBrowser"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
</activity>