Easy MPEG-DASH streaming with Multimedia for Android Library [open source]

Today we are happy to tell you that our Multimedia for Android Library is released as an open source project on the SonyXperiaDev GitHub. With the Multimedia for Android Library you can stream MPEG-DASH (Dynamic Adaptive Streaming over HTTP) content in an easy and familiar way. In this article Jimmy Dahlqvist and Martin Danielsson, Software engineers at Sony, tell you how to use this library in your app.

Martin Danielsson and Jimmy Dahlqvist, Software engineers at Sony.

Martin Danielsson and Jimmy Dahlqvist, Software engineers at Sony.

What is the Multimedia for Android Library?
The Multimedia for Android Library contains an application level media player to playback MPEG-DASH streaming content. Since the standard Android MediaPlayer API doesn’t support MPEG-DASH streaming, you would need to implement parsing and playback in your app to make it possible, which can be a very time consuming task. The Multimedia for Android Library, however, offers an easy way to do so. It’s created to be very similar to the standard Android MediaPlayer API, which makes it intuitive to use if you are an experienced Android developer.

For detailed information about content support check out the readme file on GitHub.

How to use the Multimedia for Android Library in your app
To use the Multimedia for Android Library, you need to have the Android SDK and Android Studio installed. The Multimedia for Android Library requires API level 19 (KitKat) or above, and contains an Android Studio project for both the library and a demo application.

To incorporate the Multimedia for Android Library in your application, and start using it, follow the simple steps below.

  1. Start by cloning the Multimedia for Android Library git on GitHub.
  1. Open the Multimedia for Android Library project in Android Studio.
  1. Build a jar file using the gradle scripts in the project. Note: As an alternative to steps 1–3, you can download the latest pre-built jar file from GitHub. Further instructions can be found at the GitHub Git Reference site.
  1. Save the jar file (or the downloaded pre-built jar file) to a location of your choice in your app project.
  1. Open your app project and add the jar file as a build dependency.

With the jar file incorporated in your application project, you can now create and use the mediaplayer in your app. Use the following commands in your code to create a mediaplayer and play a video.

  1. Create a multimedia player:

    MediaPlayer player = new MediaPlayer();
  2. Submit the path to the MPD file which contains links to the audio and video files you want to play:

    player.setDataSource(<path to MPD file>);
  3. Set the surface to render the video data on:

    player.setDisplay(<surface>);
  4. Prepare the multimedia player for playback:

    player.prepare();
  5. Start the multimedia player and playback the video:

    player.play();

For more details you can check out the Multimedia Library demo application code.

Can you help us improve the Multimedia for Android Library?
If you like to contribute to the Multimedia Library project, we’re happy to take in your contributions. Send us a pull request with your improvements through GitHub and we will check them out. And as always, drop us a line below if you have any questions or comments.

More information

Comments 1

Sort by: Newest | Oldest | Most popular

  1. By Dimitrios Dimopoulos

    #1

    Hello ,

    I used the Media-Player and i was wondering about the amount of sements that the player needs to start playing.
    Can I change it somehow?

    I also tested video pauses and checked that it starts again after 5 segment(approximatelly). Is this correct?

    I used the video dataset on http://www-itec.uni-klu.ac.at/dash/?page_id=6 .

    Dimitris

1-1 of 1 comments.