Categories: DRM | Multimedia | Code Examples | How To
This page was last modified 08:33, 1 August 2007.
Implementing Drm player in Symbian
From Forum Nokia Wiki
Contents |
Header File
#ifndef __SampleDrmplayerUtility_H__ #define __SampleDrmplayerUtility_H__ // INCLUDE FILES #include <e32base.h> #include <e32std.h> #include <etel.h> #include <etel3rdparty.h> #include <drmaudiosampleplayer.h> //FORWARD DECLARATION class MDrmAudioPlayerCallback; // Following two lines are added to Uplink audio on the voice call channel #define KAudioPriority 80 #define KAudioPreference 0x00060001 class CSampleDrmplayerUtility : public CActive, public MDrmAudioPlayerCallback { public: // Constructors and destructors //================================================================= // NewL // Two-phased constructor. // Creates a CSampleDrmplayerUtility object using two phase construction, // and returns a pointer to the created object. // @return A pointer to the created instance of CSampleDrmplayerUtility. //================================================================= // static CSampleDrmplayerUtility* NewL(); void RunL(); void DoCancel(); //================================================================= // NewLC // Two-phased constructor. // Creates a CSampleDrmplayerUtility object using two phase construction, // and returns a pointer to the created object. // @return A pointer to the created instance of CSampleDrmplayerUtility. //================================================================= // static CSampleDrmplayerUtility* NewLC(); //================================================================= // CSampleDrmplayerUtility // C++ default Destructor. // Destroys the object and release all memory objects. // @Return //================================================================= virtual ~CSampleDrmplayerUtility(); private: // Constructors and destructors //================================================================= // CSampleDrmplayerUtility // C++ default constructor can NOT contain any code, that might leave. // @Return //================================================================= CSampleDrmplayerUtility(); //================================================================= // ConstructL // Symbian 2nd phase constructor can leave. //================================================================= // void ConstructL(); // FOR DRMPLAYER CALLBACKS void MdapcInitComplete (TInt aError, const TTimeIntervalMicroSeconds & aDuration ); void MdapcPlayComplete (TInt aError); public: // APIs exposed to other parties void Playmusic(); void Answercall(); void Stop(); private: CDrmPlayerUtility* iMdaAudioPlayerUtility; CTelephony *iTelephony; CTelephony::TCallId iCallid; }; #endif // __SampleDrmplayerUtility_H__
Source File
#include <e32std.h> // For system wide contents #include <eikmenup.h> #include <eikapp.h> #include <aknutils.h> #include <aknnotewrappers.h> #include "SampleDrmplayerUtility.h" // CONSTANTS const TTimeIntervalMicroSeconds MaxRecordLength(10000000); #define KAudioPrefVoiceRec 0x00060001 const TInt KAudioPriorityAudioPlaybackStreaming = 80; _LIT( KSampleDrmTestFile, "C:\\Data\\Sounds\\Digital\\Baba.amr" ); // ========================= MEMBER FUNCTIONS ================================== //================================================================= // CSampleDrmplayerUtility // C++ default constructor can NOT contain any code, that might leave. // @Return //================================================================= CSampleDrmplayerUtility::CSampleDrmplayerUtility() :CActive(EPriorityStandard) { // No implementation required } //================================================================= // NewL // Two-phased constructor. // Creates a SampleDrmplayerUtility object using two phase construction, // and returns a pointer to the created object. // @return A pointer to the created instance of SampleDrmplayerUtility. //================================================================= // CSampleDrmplayerUtility* CSampleDrmplayerUtility::NewL() { CSampleDrmplayerUtility* self = NewLC(); CleanupStack::Pop( self ); return self; } //================================================================= // NewLC // Two-phased constructor. // Creates a SampleDrmplayerUtility object using two phase construction, // and returns a pointer to the created object. // @return A pointer to the created instance of SampleDrmplayerUtility. //================================================================= // CSampleDrmplayerUtility* CSampleDrmplayerUtility::NewLC() { CSampleDrmplayerUtility* self = new ( ELeave ) CSampleDrmplayerUtility(); CleanupStack::PushL( self ); self->ConstructL(); return self; } //================================================================= // ~SampleDrmplayerUtility // C++ default Destructor. // @Return //================================================================= CSampleDrmplayerUtility::~CSampleDrmplayerUtility() { Stop(); Cancel(); delete iTelephony; delete iMdaAudioPlayerUtility; } //================================================================= // ConstructL // Symbian 2nd phase constructor can leave. //================================================================= // void CSampleDrmplayerUtility::ConstructL() { CActiveScheduler::Add(this); TBuf<128> iFileName; iFileName.Append(KSampleDrmTestFile); iMdaAudioPlayerUtility=CDrmPlayerUtility::NewFilePlayerL (iFileName,*this,80,(TMdaPriorityPreference)0x00060001); iTelephony=CTelephony::NewL(); } void CSampleDrmplayerUtility::Playmusic() { if(!iMdaAudioPlayerUtility) { iMdaAudioPlayerUtility = CDrmPlayerUtility::NewFilePlayerL ( KSampleDrmTestFile, *this, 80, (TMdaPriorityPreference)0x00060001 ); } User::LeaveIfNull( iMdaAudioPlayerUtility ); iMdaAudioPlayerUtility->Play(); } void CSampleDrmplayerUtility::Answercall() { iTelephony->AnswerIncomingCall(iStatus,iCallid); SetActive(); } void CSampleDrmplayerUtility::Stop() { iMdaAudioPlayerUtility->Stop(); } //end of file void CSampleDrmplayerUtility::RunL() { CEikonEnv::InfoWinL(_L("Call Answered"),_L("")); } void CSampleDrmplayerUtility::DoCancel() { CTelephony::CancelAsync( CTelephony::EAnswerIncomingCallCancel ); } void CSampleDrmplayerUtility::MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds & aDuration ) { TBuf<10> err1; err1.AppendNum(aError); CEikonEnv::InfoWinL(_L("initialisation completed"),err1); } void CSampleDrmplayerUtility::MdapcPlayComplete(TInt aError) { TBuf<10> err2; err2.AppendNum(aError); CEikonEnv::InfoWinL(_L("play completed"),err2); }
Usage and Call of Functions
CSampleDrmplayerUtility* iDrmplayer; iDrmplayer = CSampleDrmplayerUtility::NewL(); iDrmplayer->Answercall(); iDrmplayer->Playmusic(); iDrmplayer->Stop(); if(iDrmplayer) { delete iDrmplayer; iDrmplayer=NULL; }
Internal links
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to deploy OMA DRM forward locked application on mobile | contactabbas | Digital Rights Management & Content Downloading | 1 | 2006-11-17 11:59 |
| OMA DRM Forward Lock? | ronald29 | Symbian Signing, Certification and Security | 2 | 2006-10-18 11:15 |
| Nokia3230不能播放Amr? | djypanda | Other Programming Discussion 关于其他编程技术的讨论 | 1 | 2006-04-10 11:46 |
| How to create Drm 2.0 Seperate Delivery content in NMIT | Nivas | General Messaging | 1 | 2007-08-27 10:24 |
| Opening DRM protected files from a MIDlet. | balagopalks | Mobile Java General | 1 | 2006-04-19 16:31 |
