This SDK aims at easily embedding Brid.tv videos on your Android application. It's based on ExoPlayer and supports Android 4.1 (API level 16) and later.
The easiest way to get started using BridPlayer is to add it as a gradle dependency. First, you need to add maven repository to the build.gradle file in the root of your project:
repositories {
jcenter()
maven { url 'http://52.42.57.126:8081/artifactory/libs-release-local' }
}
Next, add a gradle compile dependency to the build.gradle file of your app module:
compile 'tv.brid.sdk:bridsdk:0.0.3'
Add the following directives to the application tag:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
First, add the FrameLayout holder in your layout where you want player to show.
<FrameLayout
android:id="@+id/videoHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Then in your Activity code just instantiate new BridPlayer in that layout:
FrameLayout videoHolder = findViewById(R.id.videoHolder);
BridPlayer bridPlayer = new BridPlayer(this, videoHolder);
And load video or playlist:
bridPlayer.loadVideo(playerId, videoId);
bridPlayer.loadPlaylist(playerId, playlistId);
Your activity/fragment should take care of resources on pausing/resuming/destroying:
@Override
public void onResume() {
super.onResume();
bridPlayer.onResume();
}
@Override
public void onPause() {
super.onPause();
bridPlayer.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
bridPlayer.release();
}
For the screen rotation to be handled correctly, you need to add:
android:configChanges="orientation|screenSize"
to any activity using BridPlayer (in your AndroidManifest.xml)
To view debug messages, call the following method after creating BridPlayer object:
bridPlayer.setDebug(BridPlayer.DEBUG_ALL);
You can set debug level using the following constants: BridPlayer.DEBUG_LOG, BridPlayer.DEBUG_ERRORS, BridPlayer.DEBUG_ADS, BridPlayer.DEBUG_ANALYTICS, BridPlayer.DEBUG_ALL. For example:
bridPlayer.setDebug(BridPlayer.DEBUG_ADS | BridPlayer.DEBUG_ANALYTICS);
To monitor player events you can set listener:
bridPlayer.setListener(new BridPlayer.BridPlayerListener() {
@Override
public void onEvent(String status) {
Log.d("PLAYER EVENT", status);
}
});
Force autoplay:
bridPlayer.setAutoPlay(true);
Get index of video currently playing:
bridPlayer.getCurrentVideo();
Get position in the video:
bridPlayer.getCurrentPosition();
Other methods:
bridPlayer.play();
bridPlayer.togglePlay();
bridPlayer.pause();
bridPlayer.previous();
bridPlayer.next();
bridPlayer.setFullscreen(<true|false>);
bridPlayer.seekTo(<seek_position_milliseconds>);
bridPlayer.setLoadingIndicator(<true|false>);
This class can be used if you want to show fake player (poster image with play button and video title). You might find it useful in situations when you plan to launch video in a new activity, and don't need full featured player there. Consider using this approach when you need to show several players in the same activity or fragment.
BridPoster bridPoster = new BridPoster(this, videoHolder);
bridPoster.loadVideo(335, 186483);
bridPoster.setListener(new BridPoster.BridPosterListener() {
if (event.equals(BridPoster.EVENT_PLAY_CLICKED)) {
int playerId = data.getInt("playerId");
int videoId = data.getInt("videoId");
int playlistId = data.getInt("playlistId");
}
});
If layout background is dimmed (e.g. in dialog fragments), opacity of videos will be affected in some Android versions. This can be avoided by removing layout dimming (or decreasing it to acceptable level). See the included VideoFragment.java example.
If you're using Google API in your project, please use version 11.4.2.