williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __COESNDPY_H__ williamr@2: #define __COESNDPY_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: class TBaSystemSoundType; williamr@2: class CCoeSoundPlayerManager; williamr@2: williamr@2: williamr@2: /** Utility class for simple sound playing. williamr@2: williamr@2: Must be used in the same thread as an active UI Control Framework environment williamr@2: (CCoeEnv). williamr@2: williamr@2: This class plays the sound specified by a TBaSystemSoundType object. The williamr@2: caller can request the sound to be repeated, and the time between repeats. williamr@2: If the exact sound cannot be found on a particular device, a match only by williamr@2: category (first UID) is used. No sound will play if a match is not found. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: class CoeSoundPlayer williamr@2: { williamr@2: public: williamr@2: enum { ENoRepeat=1, ERepeatForever=KMaxTInt}; williamr@2: public: williamr@2: inline static void PlaySound(const TBaSystemSoundType& aType); williamr@2: inline static void PlaySound(const TBaSystemSoundType& aType,TInt aPlayCount,const TTimeIntervalMicroSeconds32& aGap); williamr@2: inline static void PlaySoundNow(const TBaSystemSoundType& aType); williamr@2: inline static void PlaySoundNow(const TBaSystemSoundType& aType,TInt aPlayCount,const TTimeIntervalMicroSeconds32& aGap); williamr@2: IMPORT_C static void CancelSound(const TBaSystemSoundType& aType); williamr@2: private: williamr@2: IMPORT_C static void PlaySound(const TBaSystemSoundType& aType,TInt aPlayCount, williamr@2: TTimeIntervalMicroSeconds32 aGap,TBool aInterrupt); williamr@2: static CCoeSoundPlayerManager* ManagerL(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** Plays the specified sound. williamr@2: williamr@2: This function only interrupts another, currently playing, sound if the new williamr@2: sound has a higher priority than the currently playing sound. If you wish williamr@2: to interrupt any currently playing sound and play a new one, use PlaySoundNow() williamr@2: instead of PlaySound(). williamr@2: williamr@2: @param aType The sound to play.*/ williamr@2: inline void CoeSoundPlayer::PlaySound(const TBaSystemSoundType& aType) williamr@2: {CoeSoundPlayer::PlaySound(aType,ENoRepeat,TTimeIntervalMicroSeconds32(0),EFalse);} williamr@2: williamr@2: /** Plays the specified sound for the specifed number of times with the specified williamr@2: interval. williamr@2: williamr@2: This function only interrupts another, currently playing, sound if the new sound williamr@2: has a higher priority than the current one. If you wish to interrupt williamr@2: any currently playing sound and play a new one, use PlaySoundNow() instead of PlaySound(). williamr@2: williamr@2: @param aType The sound to play. williamr@2: @param aPlayCount The number of times the sound is played. williamr@2: @param aGap The interval in microseconds between each time the sound is played. */ williamr@2: inline void CoeSoundPlayer::PlaySound(const TBaSystemSoundType& aType,TInt aPlayCount,const TTimeIntervalMicroSeconds32& aGap) williamr@2: {CoeSoundPlayer::PlaySound(aType,aPlayCount,aGap,EFalse);} williamr@2: williamr@2: /** Plays the specified sound, interrupting any other sound that is currently playing. williamr@2: williamr@2: @param aType The sound to play. */ williamr@2: inline void CoeSoundPlayer::PlaySoundNow(const TBaSystemSoundType& aType) williamr@2: {CoeSoundPlayer::PlaySound(aType,ENoRepeat,TTimeIntervalMicroSeconds32(0),ETrue);} williamr@2: williamr@2: /** Plays the specified sound the specifed number of times with the williamr@2: specified interval, interrupting any other sound that is currently playing. williamr@2: williamr@2: @param aType The sound to play. williamr@2: @param aPlayCount The number of times the sound is played. williamr@2: @param aGap The interval in microseconds between each time the sound is played. */ williamr@2: inline void CoeSoundPlayer::PlaySoundNow(const TBaSystemSoundType& aType,TInt aPlayCount,const TTimeIntervalMicroSeconds32& aGap) williamr@2: {CoeSoundPlayer::PlaySound(aType,aPlayCount,aGap,ETrue);} williamr@2: williamr@2: #endif // __COESNDPY_H__