eventsui/eventsutils/inc/evttoneplayer.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  File Player Utility.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_EVTTONEPLAYER_H
       
    20 #define C_EVTTONEPLAYER_H
       
    21 
       
    22 // System Includes
       
    23 #include <e32base.h>
       
    24 #include <DrmAudioSamplePlayer.h>
       
    25 #include <mdaaudiotoneplayer.h>
       
    26 #include <mda/common/controller.h>
       
    27 
       
    28 // User Includes
       
    29 #include "evtprofilehandler.h"
       
    30 #include "evtcallhandler.h"
       
    31 
       
    32 //Forward Declaration
       
    33 class CEvtProfileHandler;
       
    34 
       
    35 // Class Definition
       
    36 /**
       
    37  *  Interface class to observe for completion of tone playing.
       
    38  *
       
    39  *  @lib 
       
    40  *  @since S60 v9.1
       
    41  */
       
    42 class MEvtTonePlayObserver
       
    43     {
       
    44 public:
       
    45     /**
       
    46      * This will notify the tone Player observer on the completion
       
    47      * of tone play.
       
    48      * @param aTimeout Boolean value to indicate if the tone play 
       
    49 	 * was complete due to timeout.             
       
    50      */
       
    51     virtual void TonePlayCompleteL( TBool aTimeout )=0;
       
    52 
       
    53     };
       
    54     
       
    55 /**
       
    56  *  Interface class to play an Audio File.
       
    57  *  This class allows for an audio file to be played. 
       
    58  *  This class also allows for monitoring any incoming calls and
       
    59  *  give the priority for the incoming call tone.
       
    60  *
       
    61  *  @lib 
       
    62  *  @since S60 v9.1
       
    63  */
       
    64 NONSHARABLE_CLASS( CEvtTonePlayer ): public CBase, public MDrmAudioPlayerCallback,
       
    65 													 public MMdaAudioToneObserver,
       
    66 													 public MEvtProfileObserver,
       
    67 													 public MEvtCallObserver
       
    68 {
       
    69 public:
       
    70     /**
       
    71      * Constructs a new instance of Tone Player.
       
    72      *
       
    73      * @return The new instance of Tone Player object.
       
    74      * @leave System wide error code if the object creation fails.         
       
    75      */
       
    76     IMPORT_C static CEvtTonePlayer* NewL( MEvtTonePlayObserver& aObserver );
       
    77     
       
    78     /**
       
    79      * Constructs a new instance of Tone Player.
       
    80      * Leaves the created instance on the cleanup stack.
       
    81      *
       
    82      * @return The new instance of Tone Player object.
       
    83      * @leave System wide error code if the object creation fails.         
       
    84      */
       
    85     IMPORT_C static CEvtTonePlayer* NewLC( MEvtTonePlayObserver& aObserver );  
       
    86 
       
    87     /**
       
    88     * Destructor.
       
    89     */
       
    90     IMPORT_C virtual ~CEvtTonePlayer();
       
    91 
       
    92 public:  // Public Functions	
       
    93     /**
       
    94      * Initializes the player to play an audio file.
       
    95      *
       
    96      * @since S60 v9.1  
       
    97      * @param[in] aAudioFileName Audio file name
       
    98      * @param[in] aLoop Audio Loop for playing
       
    99      * @param[in] aTimeInterval Time Interval for playing in Seconds
       
   100      * @leave KErrNotFound If the file does not exist.
       
   101      */
       
   102 	IMPORT_C void PlayFileL( const TFileName& aAudioFileName, 
       
   103 				TBool aLoop, TInt aTimeInterval );
       
   104 	
       
   105     /**
       
   106      * Stops the currently playing audio file.
       
   107      *
       
   108      * @since S60 v9.1  
       
   109      * @param[in] aAudioFileName Audio file name
       
   110      */
       
   111 	IMPORT_C void StopPlayingL( TBool aTimeout );
       
   112 
       
   113 private: // From MDrmAudioPlayerCallback
       
   114     /**
       
   115      * Framework will notify you the end of the playback by a call to
       
   116      * MapcPlayComplete().
       
   117      */
       
   118 	void MdapcPlayComplete( TInt aError );
       
   119 	
       
   120     /**
       
   121      * Framework will notify you the end of the initalizing of a player
       
   122      * file by a call to MdapcInitComplete().
       
   123      */
       
   124 	void MdapcInitComplete( TInt aError, 
       
   125 							const TTimeIntervalMicroSeconds& aDuration );
       
   126 							
       
   127 private: // from MMdaAudioToneObserver
       
   128     /**
       
   129      * Framework will notify you at the end of prepare is completed
       
   130      */
       
   131     void MatoPrepareComplete(TInt aError);
       
   132     
       
   133     /**
       
   134      * Framework will notify you the end of the playback.
       
   135      */
       
   136     void MatoPlayComplete(TInt aError);
       
   137 							
       
   138 private: // from MEvtProfileObserver
       
   139     void HandleProfileSettingsChange( );
       
   140     
       
   141     // from MEvtCallObserver
       
   142     void HandleIncomingCallL( );
       
   143 
       
   144 private: 
       
   145     
       
   146     /**
       
   147      * Start the Timer.
       
   148      */
       
   149 	void StartTimerL( TInt aTimeInterval );
       
   150     
       
   151     /**
       
   152      * Stop the Timer.
       
   153      */
       
   154 	void StopTimer();
       
   155     
       
   156     /**
       
   157      * Stop the playing file.
       
   158      */
       
   159 	void Stop();
       
   160 	
       
   161     /**
       
   162      * Called when timer is expired
       
   163      */
       
   164     static TInt TickL( TAny* aObject );
       
   165 
       
   166     /**
       
   167      * Set volume between zero and player's maximum volume
       
   168      */    
       
   169     TInt PlayerVolume(TInt aPlayerMaxVol, TInt aVol);
       
   170     
       
   171     /**
       
   172      * Default C++ Constructor.
       
   173      */
       
   174 	CEvtTonePlayer( MEvtTonePlayObserver& aObserver );
       
   175 
       
   176     /**
       
   177      * Second phase of the two phase constructor.
       
   178      */
       
   179     void ConstructL();
       
   180 
       
   181 private: // Enums
       
   182 	/**
       
   183 	 * @enum TState
       
   184 	 * Player State.
       
   185 	 *
       
   186 	 */
       
   187 	enum TState
       
   188 	    {
       
   189 	    /**
       
   190 	     * Player State for Not Ready.
       
   191 	     */
       
   192 	    ENotReady                            = 1,
       
   193 	    /**
       
   194 	     * Player State for Ready.
       
   195 	     */
       
   196 	    EReady                               = 2,
       
   197 	    /**
       
   198 	     * Player State for Playing.
       
   199 	     */
       
   200 	    EPlaying                             = 3,
       
   201 	    /**
       
   202 	     * Player State for Stop.
       
   203 	     */
       
   204 	    EStop                                = 4
       
   205 	    };
       
   206 
       
   207 private: // data
       
   208 
       
   209 	/**
       
   210 	 * Tone Player Observer.
       
   211 	 */
       
   212 	 MEvtTonePlayObserver& iObserver;
       
   213 	 
       
   214 	/**
       
   215 	 * DRM Player instance.
       
   216 	 * Own:
       
   217 	 */
       
   218 	CMdaAudioToneUtility* iTonePlayer;
       
   219 	 
       
   220 	/**
       
   221 	 * DRM Player instance.
       
   222 	 * Own:
       
   223 	 */
       
   224 	CDrmPlayerUtility* iAudioPlayer;
       
   225 	 
       
   226 	/**
       
   227 	 * Profile Handler instance.
       
   228 	 * Own:
       
   229 	 */
       
   230 	CEvtProfileHandler* iProfileHandler;
       
   231 	 
       
   232 	/**
       
   233 	 * Call Handler instance.
       
   234 	 * Own:
       
   235 	 */
       
   236 	CEvtCallHandler* iCallHandler;
       
   237 	
       
   238 	/**
       
   239 	 * Periodic Timer active object.
       
   240 	 * Own:
       
   241 	 */
       
   242 	CPeriodic* iTimer; 
       
   243 	
       
   244 	/**
       
   245 	 * Audio Player State.
       
   246 	 */
       
   247 	TState iPlayerState;
       
   248 };
       
   249 
       
   250 #endif C_EVTTONEPLAYER_H