Git Product home page Git Product logo

dailymotion-sdk-android's Introduction

Dailymotion Android Web-SDK

This SDK aims at easily embedding Dailymotion videos on your Android application using WebView. It supports Android 2.3 and superior. Although it is Android Studio and Gradle based, it can easily be used in Eclipse. 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 2.3 and superior

How to use

Add the SDK to your project

You can either import the SDK using your IDE or integrate DMWebVideoView.java in your project.

Edit your AndroidManifest.xml file

Add the below to the application tag:

android:hardwareAccelerated="true"

<uses-permission android:name="android.permission.INTERNET" />

Use in your Activity or Fragment

First, add the DMWebVideoView in your layout in place of the regular WebView.

   <com.dailymotion.websdk.DMWebVideoView
        android:layout_width="300dip"
        android:layout_height="200dip"
        android:id="@+id/dmWebVideoView"
    />

Then in your Activity code just launch your content. You have two options. If your web page contains more than just a video, load the url content like this :

  	private DMWebVideoView mVideoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen_sample);

        mVideoView = ((DMWebVideoView) findViewById(R.id.dmWebVideoView));
        mVideoView.loadUrl("http://orange.jobs/jobs/mobi.do?do=getOffer&lang=FR&id=28866");

    }

If you have the id of a video on Dailymotion, then you can set it directly :

	private DMWebVideoView mVideoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen_sample);

        mVideoView = ((DMWebVideoView) findViewById(R.id.dmWebVideoView));
        mVideoView.setVideoId("x10iisk");


    }

Handling back button

Your activity must take care of the back button so as to leave fullscreen and not the current Activity :

	 @Override
        public void onBackPressed() {
            mVideoView.handleBackPress(this);
        }

Handle screen rotation

For the screen rotation to be handled correctly, you need to add

android:configChanges="orientation|screenSize"

to any activity using DMWebVideoView, in your AndroidManifest.xml

Handling automatic fullscreen

You can prevent the application to automatically switch to native fullscreen with setAllowAutomaticNativeFullscreen(boolean) method Please note that this only has effect Android 3.x and superior

Auto play

You can make the video to start as soon as the player is loaded. To do so, either call setAutoPlay(true) before setting the id of your video or call setVideoId(<video_id>, true)

Lifecycle

On Android 3.0+, 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();
    }
}

dailymotion-sdk-android's People

Contributors

martinbonnin avatar

Watchers

David Ryan avatar James Cloos avatar

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.