javauis/mmapi_qt/baseline/inc/cmmamidiplayer.h
branchRCL_3
changeset 24 0fd27995241b
equal deleted inserted replaced
20:f9bb0fca356a 24:0fd27995241b
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  This class is used for playing MIDI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMAMIDIPLAYER_H
       
    20 #define CMMAMIDIPLAYER_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include "cmmaplayer.h"
       
    25 #include <midiclientutility.h>
       
    26 #include <e32base.h>
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT(KMMAMIDIPlayer, "MIDIPlayer");
       
    30 
       
    31 const TMdaPriorityPreference KMMAMIDIPriorityPreference =
       
    32     EMdaPriorityPreferenceTimeAndQuality;
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class MMAFunctionServer;
       
    36 
       
    37 //  CLASS DECLARATION
       
    38 /**
       
    39 *   This class is used for playing MIDI.
       
    40 *
       
    41 *
       
    42 */
       
    43 
       
    44 class CMMAMIDIPlayer : public CMMAPlayer, public MMidiClientUtilityObserver
       
    45 {
       
    46 public: // Construction
       
    47     static CMMAMIDIPlayer* NewLC(const TDesC& aContentType,
       
    48                                  TFileName aFileName);
       
    49 
       
    50     //   Destructor
       
    51     ~CMMAMIDIPlayer();
       
    52 
       
    53 protected:
       
    54     //   C++ constructor
       
    55     CMMAMIDIPlayer(TFileName aFileName);
       
    56     void ConstructL(const TDesC& aContentType);
       
    57 
       
    58 public: // new methods
       
    59     IMPORT_C CMidiClientUtility* MidiClient() const;
       
    60     void ReInitializeMidiEngineL(const TDesC8* aMidiSequence);
       
    61     void addObserverL(MMidiClientUtilityObserver* aObserver);
       
    62 
       
    63 public: // from CMMAPlayer
       
    64     void StartL();
       
    65     void StopL(TBool aPostEvent);
       
    66     void RealizeL();
       
    67     void PrefetchL();
       
    68     void DeallocateL();
       
    69     void GetDuration(TInt64* aDuration);
       
    70     void SetMediaTimeL(TInt64* aTime);
       
    71     void GetMediaTime(TInt64* aMediaTime);
       
    72     void CloseL();
       
    73     const TDesC& Type();
       
    74 
       
    75 public: // from CMMAPlayer/MMMASourceStreamListener
       
    76     void ReadCompletedL(TInt aStatus, const TDesC8& aData);
       
    77     void PlayCompleteL(TInt aError);
       
    78 
       
    79 public: // from MMidiClientUtilityObserver
       
    80     void MmcuoStateChanged(TMidiState aOldState,TMidiState aNewState,const TTimeIntervalMicroSeconds& aTime,TInt aError);
       
    81     void MmcuoTempoChanged(TInt aMicroBeatsPerMinute);
       
    82     void MmcuoVolumeChanged(TInt aChannel,TReal32 aVolumeInDecibels);
       
    83     void MmcuoMuteChanged(TInt aChannel,TBool aMuted);
       
    84     void MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats);
       
    85     void MmcuoMetaDataEntryFound(const TInt aMetaDataEntryId,const TTimeIntervalMicroSeconds& aPosition);
       
    86     void MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& aMessage);
       
    87     void MmcuoPolyphonyChanged(TInt aNewPolyphony);
       
    88     void MmcuoInstrumentChanged(TInt aChannel,TInt aBankId,TInt aInstrumentId);
       
    89 
       
    90 protected:
       
    91     void CloseClientUtility();
       
    92 
       
    93 private: // Data
       
    94     CMidiClientUtility* iMidi;
       
    95 
       
    96     // CActiveShedulerWait object for reinitializing midi engine
       
    97     CActiveSchedulerWait* iActiveSchedulerWait;
       
    98 
       
    99     // Array for subsequent MMidiClientUtilityObservers
       
   100     RPointerArray<MMidiClientUtilityObserver> iObservers;
       
   101 
       
   102     TFileName iFileName;
       
   103 
       
   104     /**
       
   105     * Cached media time
       
   106     */
       
   107     TInt64 iMediaTime;
       
   108 
       
   109     /**
       
   110     * The time that will be sent with CMMAPlayerEvent::EStarted
       
   111     * (may be different from iMediaTime).
       
   112     */
       
   113     TInt64 iStartedEventTime;
       
   114 };
       
   115 
       
   116 #endif // CMMAMIDIPLAYER_H