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.
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.
- Start by cloning the Multimedia for Android Library git on GitHub.
- Open the Multimedia for Android Library project in Android Studio.
- 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.
- Save the jar file (or the downloaded pre-built jar file) to a location of your choice in your app project.
- 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.
- Create a multimedia player:
MediaPlayer player = new MediaPlayer();
- 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>);
- Set the surface to render the video data on:
- Prepare the multimedia player for playback:
- Start the multimedia player and playback the video:
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.