66
|
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 volume setting
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMMAVOLUMECONTROL_H
|
|
20 |
#define CMMAVOLUMECONTROL_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include "cmmacontrol.h"
|
|
24 |
#include "mmmaplayerstatelistener.h"
|
|
25 |
#include <MProfileChangeObserver.h>
|
|
26 |
|
|
27 |
// CONSTANS
|
|
28 |
_LIT(KMMAVolumeControlName, "VolumeControl");
|
|
29 |
const TInt KMMAVolumeMaxLevel = 100;
|
|
30 |
|
|
31 |
class CMMAPlayer;
|
|
32 |
class CProfileChangeNotifyHandler;
|
|
33 |
// CLASS DECLARATION
|
|
34 |
/**
|
|
35 |
* This class is used for volume setting
|
|
36 |
*
|
|
37 |
*
|
|
38 |
*/
|
|
39 |
|
|
40 |
class CMMAVolumeControl : public CMMAControl,
|
|
41 |
public MMMAPlayerStateListener,
|
|
42 |
public MProfileChangeObserver
|
|
43 |
{
|
|
44 |
public:
|
|
45 |
static void StaticSetLevelL(CMMAVolumeControl* aVolumeControl,
|
|
46 |
TInt aLevel);
|
|
47 |
static void StaticGetLevelL(CMMAVolumeControl* aVolumeControl,
|
|
48 |
TInt* aLevel);
|
|
49 |
|
|
50 |
IMPORT_C ~CMMAVolumeControl();
|
|
51 |
|
|
52 |
protected:
|
|
53 |
IMPORT_C CMMAVolumeControl(CMMAPlayer* aPlayer);
|
|
54 |
IMPORT_C void ConstructBaseL();
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Sets the level to player.
|
|
58 |
* @param aLevel Sound level to set.
|
|
59 |
*/
|
|
60 |
virtual void DoSetLevelL(TInt aLevel) = 0;
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Get volume level from player.
|
|
64 |
* @return Current level.
|
|
65 |
*/
|
|
66 |
virtual TInt DoGetLevelL() = 0;
|
|
67 |
|
|
68 |
public: // From CMMAControl
|
|
69 |
IMPORT_C const TDesC& ClassName() const;
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Refresh volume control.
|
|
73 |
*/
|
|
74 |
IMPORT_C void RefreshControl();
|
|
75 |
|
|
76 |
public: // From MMMAPlayerStateListener
|
|
77 |
IMPORT_C void StateChanged(TInt aState);
|
|
78 |
|
|
79 |
public: // from MProfileChangeObserver
|
|
80 |
IMPORT_C void HandleActiveProfileEventL(TProfileEvent aProfileEvent, TInt aProfileId );
|
|
81 |
|
|
82 |
public: // New methods
|
|
83 |
/**
|
|
84 |
* Adds new volume level to volume control. Actual volume level will
|
|
85 |
* be calculated using all levels added to the control.
|
|
86 |
* @return Index for new level.
|
|
87 |
*/
|
|
88 |
IMPORT_C TInt AddLevelL();
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Sets new volume level for certain level index. After level is set
|
|
92 |
* new actual level is calculated and commited to player in derived
|
|
93 |
* class.
|
|
94 |
* @param aLevelIndex Level's index
|
|
95 |
* @param aVolumeLevel New volume level for level index. Level must be
|
|
96 |
* between 0 and 100.
|
|
97 |
*/
|
|
98 |
IMPORT_C void SetVolumeLevelL(TInt aLevelIndex,
|
|
99 |
TInt aVolumeLevel);
|
|
100 |
void GetVolumeLevelL(TInt aLevelIndex,
|
|
101 |
TInt* aVolumeLevel);
|
|
102 |
void SetProfilesBasedSoundMutingL();
|
|
103 |
/**
|
|
104 |
* Sets the audio o/p preference. Based on this the profile based
|
|
105 |
* volume setting is done.
|
|
106 |
*/
|
|
107 |
IMPORT_C void SetAudioOutputPreferenceL( TInt aRoutingPreference);
|
|
108 |
|
|
109 |
void InitializeGlobalVolumeLevel(TInt aGlobalVolumeLevel);
|
|
110 |
|
|
111 |
private: // New methods
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Refresh volume level, basically set the volume level again.
|
|
115 |
*/
|
|
116 |
void RefreshVolume();
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Sets level if player is started and sends java event level
|
|
120 |
* changed.
|
|
121 |
* @param aLevel Sound level to set.
|
|
122 |
*/
|
|
123 |
void SetLevelL(TInt aLevel);
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Calculates new overall level using all values in iLevels array.
|
|
127 |
* @return Current level.
|
|
128 |
*/
|
|
129 |
TInt CalculateLevel();
|
|
130 |
|
|
131 |
void SetJavaSoundVolumeLevelL();
|
|
132 |
|
|
133 |
void SetProfileSoundVolumeLevelL();
|
|
134 |
protected: // data
|
|
135 |
CMMAPlayer* iPlayer;
|
|
136 |
|
|
137 |
// Previous level setted to player. Used to check if level is changed.
|
|
138 |
TInt iLevel;
|
|
139 |
|
|
140 |
// Array containing all levels.
|
|
141 |
RArray< TInt > iLevels;
|
|
142 |
// profile change notifier
|
|
143 |
// Owning
|
|
144 |
CProfileChangeNotifyHandler* iProfChangeNotifier;
|
|
145 |
// Current audio o/p preference.
|
|
146 |
TInt iAudioOutputPreference;
|
|
147 |
// Current profile Id.
|
|
148 |
TInt iProfileId;
|
|
149 |
private:
|
|
150 |
// The Global Volume level at the time when a player is created
|
|
151 |
TInt iInitialGlobalVolumeLevel;
|
|
152 |
};
|
|
153 |
|
|
154 |
#endif // CMMAVOLUMECONTROL_H
|