After spending couple of weekends on creating demo app, finally I am able to publish this post on DLNA/Upnp media management.
First of all – What is DLNA?
DLNA is a standard to facilitate access to multimedia content between devices connected within the same computer network. For more information about DLNA, see http://en.wikipedia.org/wiki/Digital_Living_Network_Alliance.
This blog post shows how to create an Android app which can –
- Browse contents of any DLNA media server and renders their content locally on Android device.
- Controls playback on other Media Renderers on same network.
- Also I have added a functionality to server local device media files to a selected Renderer device thorough hosting a NanoHttpD server in application. (Yes, not a standard DMS device, but works to serve files to other devices)
I have used CyberLinkForJava library which controls DLNA protocols automatically and supports to create your devices and control points quickly. For more info on how this library works, here is a quick programming guide for CyberLink Java.
Let’s run through the details of the demo app – Source & demo APK links are available at the end of blog post 🙂
Backbone of this app is DLNA service which starts a HandlerThread to handle lifecycle of a ControlPoint which notifies when a device is added/removed along with search response callbacks. This Service gets started in Launcher activity and runs indefinitely until we stop it.
Launcher activity hosts two listviews – PlayFrom & PlayTo. I have appended local device entry to both lists explicitly (not through search callbacks from service). You can browse through ‘PlayFrom‘ devices to pick media content to play on selected Renderer(default is local device).
BrowseDMSManager class takes care of enquiring content directories using service name: ‘urn:schemas-upnp-org:service:ContentDirectory:1‘
If you select local device to browse, I’ve used FilePickerLibrary to pick files locally and start a HttpServer to serve those files to selected Renderer device. Read my earlier blog post on how to serve local files using HttpServer, though I’ve used NanoHttpD here to handler all possible scenarios.
RemoteDlnaController class is responsible for managing communications b/w client and server devices. It has utilities to send PLAY, PAUSE, STOP, VOLUME controls etc.. actions to Renderer device.
I’ve added zoom functionality to Image Pageview and some Jazziness, thanks to TouchView, JazzyViewPager & Universal ImageLoader.
Posted demo source to my GitHub. APK is available here.
let me know what you think of it 🙂