Coder Social home page Coder Social logo

phunnpd / dailymotion-player-sdk-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dailymotion/dailymotion-player-sdk-android

0.0 1.0 0.0 864 KB

The SDK to play dailymotion videos in your Android apps

Home Page: https://dailymotion.com

License: MIT License

Kotlin 17.99% Java 82.01%

dailymotion-player-sdk-android's Introduction

Dailymotion Player SDK Android

Download Build Status

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

Features

  • Dead simple to use. No need to specify a layout container for the VideoView
  • Supports Android 3.0.x and superior

How to use

Add the SDK to your project

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" />

Use in your Activity or Fragment

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);
    }

Handle screen rotation

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

Lifecycle

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();
        }
    }

Play Services

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]"
}

Publish your own sdk on Bintray

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.