⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playeradapter.h

📁 symbian平台
💻 H
字号:
/*
* ==============================================================================
*  Name        : PlayerAdapter.h
*  Part of     : S60 Internet Radio Application
*  Interface   :
*  Description : Defines the file player adapter interface
*  Version     : 1
*
*  Copyright (c) 2006, Nokia Corporation All rights reserved. Redistribution
*  and use in source and binary forms, with or without modification, are
*  permitted provided that the following conditions are met: Redistributions
*  of source code must retain the above copyright notice, this list of
*  conditions and the following disclaimer. Redistributions in binary form
*  must reproduce the above copyright notice, this list of conditions and the
*  following disclaimer in the documentation and/or other materials provided
*  with the distribution. Neither the name of the Nokia Corporation nor the
*  names of its contributors may be used to endorse or promote products
*  derived from this software without specific prior written permission. THIS
*  SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
*  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
*  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*  POSSIBILITY OF SUCH DAMAGE.
* ==============================================================================
*/
#ifndef __CPLAYERADAPTER__
#define __CPLAYERADAPTER__

// INCLUDE FILES
#include <MdaAudioSamplePlayer.h>
#include <MAudioAdapter.h>
#include <MAdapterObserver.h>

// FORWARD DECLARATIONS

// CLASS DECLARATION

/**
*  This class defines the file player adapter for the Mda audio player utility.
*
*/
class CPlayerAdapter : public CBase,
					   public MAudioAdapter,
					   public MMdaAudioPlayerCallback
    {
	public: // Contructors

        /**
        * Factory function for a Player Adapter
        * @param aFileName the file name of the audio file to play
        * @return pointer to new object
        */
		static CPlayerAdapter* NewL(const TDesC& aFileName, MAdapterObserver& aObserver);

        /**
        * Factory function for a Player Adapter
        * @param aFileName the file name of the audio file to play
        * @return pointer to new object and leaves it on the cleanup stack
        */
    	static CPlayerAdapter* NewLC(const TDesC& aFileName, MAdapterObserver& aObserver);

        /**
        * Destructor.
        */
    	~CPlayerAdapter();

	public: // from MAudioAdapter

	    /**
        * Start playback of the audio sample.
        */
        void PlayL();

	    /**
        * Pauses the audio playback.
        */
        void PauseL();

        /**
        * Start recording. Note: Recording is not implemented and will leave with KErrNotSupported.
        */
        void RecordL();

        /**
        * Stop playback of the audio sample.
        * Note that this implementation of the virtual function does not leave.
        */
        void StopL();

        /**
        * Update the menu aMenuPane to reflect the current state of the audio player utility.
        * @param aMenuPane the menu pane to update
        */
        void UpdateMenuL(CEikMenuPane* aMenuPane);

        /**
        * Return an identifying string
        * @return An identification string
        */
        const TDesC& Identify() const;

        /**
        * Add additional items to the specified menu
        * @param aMenuPane The menu pane to which items are added
        */
        void AddExtraMenu(CEikMenuPane* aMenuPane);

        /**
        * Handles the commands from the UI
        * @param aCommand The command to be handled
        * @return ETrue if the command was handled, EFalse otherwise.
        */
		TBool HandleCommandL(TInt aCommand);

        /**
        * Get number of supported metadata
        * @return Number of supported metada
        */
		TInt SupportMetadata() const;

        /**
        * Toggles play and stop
        */
		void TogglePlayPause();

       	/**
        * Set the volume
        * @param aVolume The desired volume level
        */
		void SetVolume(TInt aVolume);

        /**
        * Get the current volume level
        * @return Volume Level
        */
		TInt Volume();

	public: // from MMdaAudioPlayerCallback

        /**
        * 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);

        /**
        * Handle the event when when the audio player utility completes asynchronous playing.
        * @param aError @param aError The status of the playback
        */
    	void MapcPlayComplete(TInt aError);

	private:

        /**
        * Perform the first phase of two phase construction
        * @param aAppUi the Ui to use
		*/
    	CPlayerAdapter(MAdapterObserver& aObserver);

        /**
        * Perform the second phase construction of a CPlayerAdapter object
        * @param aFileName the audio file
		*/
    	void ConstructL(const TDesC& aFileName);

        /**
        * Get Metadata from the file and sends it to the UI
		*/
    	void GetMetadata();
    	
        /**
        * Show the metadata
		*/
    	void ShowMetadata();

	private:

		enum TState
			{
			ENotReady,    //Not ready to play
			EReadyToPlay, //Ready to play
			EPlaying      //Playing
			};

		// The current state of the audio player utility
		TState iState;
		// The audio player utility object
		CMdaAudioPlayerUtility* iMdaAudioPlayerUtility;
		// The application's UI object
		MAdapterObserver& iObserver;
		// Volume factor used in scaling the volume
		TReal iVolFactor;
		TInt iNrMetadata;
		TBuf<200> iTempMetadata;
		TBuf<60> iMetaDataTitle;
		TBuf<60> iMetaDataArtist;
		TBuf<60> iMetaDataGenre;

    };

#endif // __CPLAYERADAPTER__

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -