javauis/mmapi_qt/src_drmv2/src/cmmadrmvolumecontrol.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     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 setting volume to DRMv2 audio player
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "logger.h"
       
    20 #include "cmmadrmvolumecontrol.h"
       
    21 #include "cmmadrmaudioplayer.h"
       
    22 
       
    23 CMMADRMVolumeControl::CMMADRMVolumeControl(CMMADRMAudioPlayer* aPlayer)
       
    24         : CMMAVolumeControl(aPlayer)
       
    25 {
       
    26     iPlayer = aPlayer;
       
    27 }
       
    28 
       
    29 void CMMADRMVolumeControl::ConstructL()
       
    30 {
       
    31     ConstructBaseL();
       
    32 }
       
    33 CMMADRMVolumeControl* CMMADRMVolumeControl::NewL(CMMADRMAudioPlayer* aPlayer)
       
    34 {
       
    35     CMMADRMVolumeControl* self = new(ELeave)CMMADRMVolumeControl(aPlayer);
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop();
       
    39     return self;
       
    40 }
       
    41 
       
    42 void CMMADRMVolumeControl::DoSetLevelL(TInt aLevel)
       
    43 {
       
    44     CDrmPlayerUtility* utility = iPlayer->DRMUtility();
       
    45     TInt maxVolume = utility->MaxVolume();
       
    46     utility->SetVolume(aLevel * maxVolume / KMMAVolumeMaxLevel);
       
    47 }
       
    48 
       
    49 TInt CMMADRMVolumeControl::DoGetLevelL()
       
    50 {
       
    51     CDrmPlayerUtility* utility = iPlayer->DRMUtility();
       
    52     TInt maxVolume = utility->MaxVolume();
       
    53     TInt volume = 0;
       
    54     User::LeaveIfError(utility->GetVolume(volume));
       
    55     // result is in range 0..100
       
    56     return (volume * KMMAVolumeMaxLevel / maxVolume);
       
    57 }
       
    58 
       
    59 //  END OF FILE