|
1 /* |
|
2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 * |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of the License "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * EmbedDev AB - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef SOUND_ENGINE_H |
|
20 #define SOUND_ENGINE_H |
|
21 #include <e32base.h> |
|
22 |
|
23 class CPodcastModel; |
|
24 |
|
25 const TInt KVolumeSteps = 10; |
|
26 |
|
27 enum TSoundEngineState |
|
28 { |
|
29 ESoundEngineNotInitialized, |
|
30 ESoundEngineOpening, |
|
31 ESoundEnginePlaying, |
|
32 ESoundEnginePaused, |
|
33 ESoundEngineStopped |
|
34 }; |
|
35 |
|
36 class MSoundEngineObserver |
|
37 { |
|
38 public: |
|
39 virtual void PlaybackInitializedL() = 0; |
|
40 virtual void PlaybackStartedL() = 0; |
|
41 virtual void PlaybackStoppedL() = 0; |
|
42 virtual void VolumeChanged(TUint aVolume, TUint aMaxVolume) = 0; |
|
43 }; |
|
44 |
|
45 |
|
46 /** |
|
47 * This class handles all playback and audio associated resources that the application/client needs |
|
48 */ |
|
49 class CSoundEngine : public CBase |
|
50 { |
|
51 public: |
|
52 static CSoundEngine* NewL(CPodcastModel& aPodcastModel); |
|
53 ~CSoundEngine(); |
|
54 void OpenFileL(const TDesC& aFileName, TBool aPlayOnInit); |
|
55 IMPORT_C void Play(); |
|
56 IMPORT_C void Stop(TBool aMarkPlayed=ETrue); |
|
57 IMPORT_C TTimeIntervalMicroSeconds Position(); |
|
58 IMPORT_C void SetPosition(TUint aPos); |
|
59 |
|
60 IMPORT_C void Pause(TBool aOverrideState = EFalse); |
|
61 |
|
62 IMPORT_C TSoundEngineState State(); |
|
63 IMPORT_C void AddObserver(MSoundEngineObserver* aObserver); |
|
64 void RemoveObserver(MSoundEngineObserver* aObserver); |
|
65 |
|
66 const TFileName& LastFileName(); |
|
67 |
|
68 private: |
|
69 void NotifyPlaybackStarted(); |
|
70 void NotifyPlaybackStopped(); |
|
71 void NotifyPlaybackInitialized(); |
|
72 void NotifyVolumeChanged(); |
|
73 |
|
74 protected: |
|
75 CSoundEngine(CPodcastModel& aPodcastModel); |
|
76 void ConstructL(); |
|
77 |
|
78 private: |
|
79 CPodcastModel& iPodcastModel; |
|
80 TSoundEngineState iState; |
|
81 RArray<MSoundEngineObserver*> iObservers; |
|
82 TFileName iLastOpenedFileName; |
|
83 TBool iPlayOnInit; |
|
84 TTimeIntervalMicroSeconds iMaxPos; |
|
85 }; |
|
86 |
|
87 #endif // SOUND_ENGINE_H |
|
88 |