Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 15:02, 24 June 2008.

Playing DRM-protected audio file using CDrmPlayerUtility

From Forum Nokia Wiki

This article explains how to play DRM-protected audio file. The standard class from Symbian, CMdaAudioPlayerUtility, cannot be used to play DRM-protected audio file. There is an API extension from S60, called CDrmPlayerUtility, to play it. Note that the example code applies to OMA DRM only. It does not play WMDRM content although the device support it.


Introduction

Most of the S60 devices support OMA DRM v1.0. However, some of them support OMA DRM v1.0 Forward-lock only. Only some devices support all of OMA DRM v1.0 protection methods, i.e. forward-lock, combined delivery and separate delivery. Some newer devices support OMA DRM v2.0, for example Nokia N73.

As the writing of this article, only a few number of S60 devices support WM-DRM. However, the code example below cannot play WM-DRM. The reason is because those devices have not integrated WM-DRM into the S60 DRM API. This situation may change in the future when WM-DRM has been supported by S60 DRM API.

To find out more information about DRM as well as how to create OMA DRM v1.0 content, take a look at some links at the end of this article.


Example code

The API to play DRM-protected audio file is very similar to the API to play unprotected file. There are some differences in the class name only.

The CDrmPlayerUtility is declared in drmaudiosampleplayer.h. Add the following line to the .cpp file that will be used to use the API.

#include <drmaudiosampleplayer.h>

The API is defined in the DrmAudioPlayUtility.lib. Add the following line to the .mmp file.

LIBRARY DrmAudioPlayUtility.lib

Note: This API does not need DRM capability in S60 3rd Edition. All DRM APIs do not need DRM capability as long as third party developers are not able to "see" the plain-text version of the data.


The following code shows a class that contains one public methods, Play(), to play DRM-protected audio file.

class CDrmAudioExample: public CBase, MDrmAudioPlayerCallback
    {
public: // Constructor and destructor
 
    CDrmAudioExample();	
    ~CDrmAudioExample();
	
public: // Public methods
 
    void PlayL(const TDesC& aFileName);
 
private: // From MdrmAudioPlayerCallback
	
    void  MdapcInitComplete(TInt aError,
        const TTimeIntervalMicroSeconds &aDuration);
    void  MdapcPlayComplete (TInt aError);
	
private: // Member variables
 
    CDrmPlayerUtility* iPlayerUtility;
    RFile iFile;
	
    };


The following code shows the implementation of the above header file.

CDrmAudioExample::CDrmAudioExample()
    {
    }
 
CDrmAudioExample::~CDrmAudioExample()
    {
    if (iPlayerUtility)
        {
        iPlayerUtility->Stop();
        delete iPlayerUtility;
        }
    iFile.Close();
    }
	
void CDrmAudioExample::PlayL(const TDesC& aFileName)
    {
    // Delete old instance of iPlayerUtility and close the file.
    if (iPlayerUtility)
        {
        iPlayerUtility->Stop();
        delete iPlayerUtility;
        iPlayerUtility = 0;
        }
    iFile.Close();
	
    // Create a new instance of iPlayerUtility and open the file.
    iPlayerUtility = CDrmPlayerUtility::NewL(
        *this, EMdaPriorityNormal, EMdaPriorityPreferenceNone);
    iFile.Open(CCoeEnv::Static()->FsSession(), aFileName,
        EFileShareReadersOnly | EFileStream | EFileRead);
    iPlayerUtility->OpenFileL(iFile);	
    }
 
void  CDrmAudioExample::MdapcInitComplete(TInt aError,
        const TTimeIntervalMicroSeconds &aDuration)
    {
    if (KErrNone == aError)
        {
        // Set the volume to half of the maximum volume.
        iPlayerUtility->SetVolume( iPlayerUtility->MaxVolume() / 2 );
        iPlayerUtility->Play();
        }
    }
 
void CDrmAudioExample::MdapcPlayComplete(TInt aError)
    {
    }

Note: The example above works on S60 3rd and 3rd MR SDK emulator. When it is run on S60 3rd FP1 SDK, the program will panic at CDrmPlayerUtility::NewL() with KERN-EXEC 0 message. Unfortunately, there is not so much information whether it is a bug in FP1 or something else.


Internal links

 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZaudioQ
     qfnZtopicQUqfnTopicZdrmQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX