Playing DRM-protected audio content

This topic provides instructions to play DRM-protected audio content using the DRM APIs.

Context

You can use the DRM Audio Player API to play DRM-protected audio content on a mobile device. If you need to read or edit the audio content, use the Content Access Framework (CAF) API.

The following is a list of all the DRM-related APIs that will be useful for handling DRM-protected content:

  • DRM Audio Player API — Allows you to play DRM-protected files without DRM capability.

  • Content Access Framework (CAF) API — Allows you to read and edit DRM content.

  • The DRM Helper API allows you to deal with DRM-specific error situations, such as getting rights details, registering and unregistering DRM-protected content for automated use, and getting details of DRM-protected content. The DRM Helper API is a library API and can be used alongside the DRM Audio Player API or the CAF API. For more information, see Symbian C++ API specifications.

  • The OMA DRM CAF Agent API allows you to access OMA DRM-specific content and rights. This API requires CAF API. For more information, see Symbian C++ API specifications.

  • The DRM License Checker API allows you to use DRM to protect data files in applications. This API is not related to the APIs above and is not necessary for playing multimedia content. For more information, see Symbian C++ API specifications.

Figure: The relationship between different DRM-related APIs

For information on downloading DRM-protected content, see Browsing & downloading, and on playing DRM-free content, see the Playing Audio Files example on Nokia Developer.

Important:

  • OMA DRM and WMDRM are not interoperable. Mobile device users are not able to use content created in one DRM system in the other one.

  • Multimedia applications consume the battery power rapidly. For information on better power management, see Power Management on Nokia Developer.

Steps

  1. Use the CDrmPlayerUtility class. CDrmPlayerUtility provides the same interface as CMdaAudioPlayerUtility. Except the class name, most of the code is same.

    The following code snippet demonstrates how to use CDrmPlayerUtility:

    #include <drmaudiosampleplayer.h>
    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)
        {
        }
    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;
    	
        };
  2. Add drmaudioplayutility.lib to the mmp file.

  3. Add DRM or MultimediaDD capabilities to the mmp flle, based on your application needs.