This post is also available in: Russian
The popularity of mobile devices is pushing most of online video projects to adapt their services to mobile applications (e.g., tablets or smart phones). In the context of many online video services needing video content protection (for example, to offer content libraries from the major Western movie studios), implementing of DRM features in a mobile video player is becoming a critical task. As always, you have a set of solutions and platforms to choose from. Recently, we wrote of DRM features in iOS. Now, it’s high time to talk about Android DRM.
First of all, in contrast to iOS, Android has implemented an API to interact with DRM solutions at the Java level. You can find the Android DRM API documentation at the official Android site. However, the benefit of this is not so apparent as there have been sparse announcements of supporting such a scheme. I suspect that this includes Widevine purchased by Google and possibly some other project. As a DRM for Android, we use Adobe Flash Access. This DRM technology is widely used for video playback in the Windows and MacOS browsers (Flash Player) and in AIR applications. In the new version, Adobe implemented DRM support on the mobile Android devices. For this purpose, Flash Player 11 and AIR 3 are used. Let’s now discuss implementation of DRM features in the Android-based Adobe Flash in more detail.
AIR 3 On Android, mobile video applications can be implemented using Adobe AIR runtime, allowing for the maximum re-use of functionality of the basic online video service (Flash video player). With the release of AIR 3 Mobile you will need to put a minimum effort to the technical part of your video player as DRM support is based on OSMF and runs identically on the other platforms (Windows, MacOS). Implementing a user interface optimized for tablets and smartphones will take much longer. If you are focused at quality, you’ll need to significantly revise the user’s interaction with the online video service and the range of features available. WatchESPN is a good example of an AIR application on Android.
If you do not need to perform authentication with a token or username/password, then you can use a simple video player code to play back the DRM content:
var factory:MediaFactory = new DefaultMediaFactory();
// create a player and add the video to it
player = new MediaPlayer(); // create a media element and add it to the container
videoElement = factory.createMediaElement(new URLResource(url));
player.media = videoElement; // start listening to the important events
player.addEventListener(PlayEvent.PLAY_STATE_CHANGE, onStateChange); player.addEventListener(DRMEvent.DRM_STATE_CHANGE, onDRMStateChange); player.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError); player.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onMPSC); // create video screen
container = new MediaContainer(); addChild(container); container.addMediaElement(videoElement);
Please note that this code is absolutely identical to a simple OSMF video player code. I told you, that would not require much effort 🙂
The very process of creating a mobile application in the Flash Builder 4.5 environment has been well described in the Adobe documentation and you are not likely to have any problems with that. Moreover, Flash Builder 4.5 allows for easy debugging of AIR applications on mobile devices. The only thing to be noted is AIR 3 installation on the user’s device. In the event that AIR 3 is not installed or has an older version, your application will not have access to DRM interfaces. You can define Adobe Flash Access support in your application using the DRMManager.isSupported property.
Flash Player 11
DRM content playback in the mobile browser is complicated because the developer has no convenient tools to detect and debug the issues, as in the case of the AIR application. On the other hand, there is a substantial benefit: compared to the PC version, a minimum change to the video player is needed. So you can test your application on a PC (after all, the main focus of Flash Player is to run a single application logic across multiple platforms). It is worth noting that Adobe has decided to discontinue development of the Flash Player plugin for mobile browsers on Android in favor of accelerating the development of mobile applications based on AIR (Flash applications). Please find more details in the Kevin Towes blog.