www.pudn.com > nokie_soundplayer.rar > playeradapter.h


/* Copyright (c) 2004, Nokia. All rights reserved */ 
 
 
 
#ifndef __CPLAYERADAPTER_H__ 
#define __CPLAYERADAPTER_H__ 
 
// INCLUDES 
#include  
#include "audioadapter.h" 
 
// FORWARD DECLARATIONS 
class CSoundAppUi; 
 
 
// CLASS DECLARATION 
 
/*  
* An instance of class CPlayerAdapter is an adapter object for  
* the CMdaAudioPlayerUtility class. 
*/ 
class CPlayerAdapter : public CBase,  
                       public MAudioAdapter,  
                       public MMdaAudioPlayerCallback 
    { 
    public: 
     
        /** 
        * NewL 
        * Two-phased constructor. 
        * Create a CPlayerAdapter object using two phase construction, 
        * and return a pointer to the created object 
        * @param aFileName the audio file 
        * @param aAppUi the User Interface 
        * @return pointer to new object 
        */ 
        static CPlayerAdapter* NewL( const TDesC& aFileName, 
                                     CSoundAppUi& aAppUi ); 
  
        /** 
        * NewLC 
        * Two-phased constructor. 
        * Create a CPlayerAdapter object using two phase construction, 
        * and return a pointer to the created object 
        * @param aFileName the audio file 
        * @param aAppUi the User Interface 
        * @return pointer to new object 
        */ 
        static CPlayerAdapter* NewLC( const TDesC& aFileName, 
                                      CSoundAppUi& aAppUi ); 
 
        /** 
        * ~CPlayerAdapter. 
        * Virtual Destructor. 
        */ 
        virtual ~CPlayerAdapter(); 
 
 
    public: // from MAudioAdapter 
 
        /** 
        * PlayL 
        * Begin playback of the audio sample.  
        */       
        void PlayL(); 
 
        /** 
        * RecordL 
        * Do nothing. Recording is not supported. 
        */ 
        void RecordL(); 
 
        /** 
        * StopL 
        * Stop playback of the audio sample. 
        * Note that this implementation of the virtual function does not leave. 
        */ 
        void StopL(); 
 
        /** 
        * UpdateMenuL 
        * Update the menu aMenuPane to reflect the current state of the  
        * audio player utility. Note that this implementation of the  
        * virtual function does not leave.  
        * @param aMenuPane the menu pane to update 
        */ 
        void UpdateMenuL( CEikMenuPane* aMenuPane ); 
 
        /** 
        * Identify 
        * Return an identifying string  
        * @return An identification string  
        */ 
        const TDesC& Identify(); 
 
     
    public: // from MMdaAudioPlayerCallback 
 
        /** 
        * MapcInitComplete 
        * Handle the event when initialisation of  
        * the audio player utility is complete. 
        * @param aError The status of the audio sample after initialisation 
        * @param aDuration The duration of the sample 
        */ 
        void MapcInitComplete( TInt aError,  
                               const TTimeIntervalMicroSeconds& aDuration ); 
 
        /** 
        * MapcPlayComplete 
        * Handle the event when when the audio player utility 
        * completes asynchronous playing. 
        * @param aError The status of playback 
        */ 
        void MapcPlayComplete( TInt aError ); 
 
    private:    // Constructors 
 
        /** 
        * CPlayerAdapter. 
        * C++ default constructor. 
        * Perform the first phase of two phase construction  
        * @param aAppUi the Ui to use 
        */ 
        CPlayerAdapter( CSoundAppUi& aAppUi ); 
     
        /** 
        * ConstructL 
        * 2nd phase constructor. 
        * @param aFileName the audio file 
        */ 
        void ConstructL( const TDesC& aFileName ); 
 
    private:    // Data 
 
        /** 
        * TState 
        * The application state 
        * - ENotReady Not ready to play 
        * - EReadyToPlay Ready to play 
        * - EPlaying Playing 
        */ 
        enum TState 
        { 
            ENotReady, 
            EReadyToPlay, 
            EPlaying 
        }; 
 
        /** iState The current state of the audio player utility. **/     
        TState iState; 
 
        /** 
        * iMdaAudioPlayerUtility. The audio player utility object. 
        * owned by CPlayerAdapter object. 
        */ 
        CMdaAudioPlayerUtility* iMdaAudioPlayerUtility; 
 
 
        /** iAppUi Reference to the application's UI object. **/ 
        CSoundAppUi& iAppUi; 
 
        /** 
        * itextResourceIdentifier. Textresource for identifier 
        * owned by CPlayerAdapter object. 
        */ 
        HBufC* itextResourceIdentifier; 
    }; 
 
#endif // __CPLAYERADAPTER_H__ 
 
 
// End of File