Playback of content
As shown in the prm-encrypted-playback example code, the use of the NMPVideoView object to control playback is the same as for Clear playback.
@Override
protected void onCreate(Bundle savedInstanceState) {
...
mNMPVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mNMPVideoView.start();
}
});
}
...
/**
* stops the video playback as the activity is paused.
*/
@Override
public void onPause() {
super.onPause();
if (mNMPVideoView != null) {
mNMPVideoView.stopPlayback();
}
}
...
/**
* Restarts the video playback from the beginning.
*/
@Override
public void onResume() {
super.onResume();
if (mNMPVideoView != null) {
mNMPVideoView.setVideoPath(mVideoURI);
mNMPVideoView.start();
}
}
The difference is in the stream's media playlist; it contains a tag indicating it is a PRM-protected stream, similar to the tag below:
#EXT-X-KEY:METHOD=AES-128,URI="http://www.nagra.com/key=38d7cb71-091c-4ec7-b801-89b9a68a45d4&prm=eyJjb250ZW50SWQiOiIzOGQ3Y2I3MS0wOTFjLTRlYzctYjgwMS04OWI5YTY4YTQ1ZDQiLCJrZXlJZCI6IjFiNGE3MGYxLTViNmYtNGVkNS04ZGM1LTJiMmM0ODRhYjdlMCJ9"
The NMP Player detects the tag and identifies the stream as PRM-protected. It then connects to the PAK (which is already initialised with OpVault and licence server) and triggers a request for license acquisition. Depending on the mode, as defined by the DRMHandlerOperationDelegate
implementation, the request is handled either by the application or by the player itself (see Using the DRMHandler class).
Next step: DRMHandler Lifecycle