This SDK aims at easily embedding Dailymotion videos on your Android application using WebView. It supports api level 14+ (Android 4.0+). The SDK is bundled with a sample application
- Dead simple to use. No need to specify a layout container for the VideoView
- Supports Android 3.0.x and superior
You can either import the SDK using your IDE or integrate PlayerWebView.java in your project.
You can import the sdk with :
implementation 'com.dailymotion.dailymotion-sdk-android:sdk:0.1.29'
android:hardwareAccelerated="true"
<uses-permission android:name="android.permission.INTERNET" />
First, add the PlayerWebView in your layout in place of the regular WebView.
<com.dailymotion.android.player.sdk.PlayerWebView
android:id="@+id/dm_player_web_view"
android:layout_width="match_parent"
android:layout_height="215dp">
</com.dailymotion.android.player.sdk.PlayerWebView>
Then in your Activity code just launch your content. Get your PlayerWebView then call load("id").
private PlayerWebView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen_sample);
mVideoView = (PlayerWebView) findViewById(R.id.dm_player_web_view);
mVideoView.load("x26hv6c");
}
You can load the video with your parameters.
private PlayerWebView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen_sample);
mVideoView = (PlayerWebView) findViewById(R.id.dm_player_web_view);
Map<String, String> playerParams = new HashMap<>();
playerParams.put("key", "value");
mVideoView.load("x26hv6c", playerParams);
}
For the screen rotation to be handled correctly, you need to add
android:configChanges="orientation|screenSize"
to any activity using PlayerWebView, in your AndroidManifest.xml
You have to call onPause and onResume when these events occur in your lifecycle :
@Override
protected void onPause() {
super.onPause();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
mVideoView.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
mVideoView.onResume();
}
}
The SDK uses Google Play Services to get the Advertising Id
If your app also uses play services, you may want to override the play-services-ads
version to avoid conflicting with other play services artifacts.
dependencies {
implementation "com.google.android.gms:play-services-ads:[your_play_services_version]"
}
Update your local.properties files with this lines and replace and <api.key> values`
bintray.user=<user>
bintray.apikey=<api.key>
In your terminal call gradlew install
then gradlew bintrayUpload