javauis/mmapi_akn/baseline/src/cmmaaudioplayerfactory.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002 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 creating wav player.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include <jdebug.h>
       
    21 #include "cmmaaudioplayerfactory.h"
       
    22 #include "cmmaaudioplayer.h"
       
    23 #include "cmmaaudiovolumecontrol.h"
       
    24 #include "cmmastoptimecontrol.h"
       
    25 #include "cmmaaudiometadatacontrol.h"
       
    26 #include "cmmammfratecontrol.h"
       
    27 
       
    28 _LIT(KMMAMP3ContentType, "audio/mp3");
       
    29 _LIT(KMMAMPEGContentType, "audio/mpeg");
       
    30 
       
    31 CMMAAudioPlayerFactory* CMMAAudioPlayerFactory::NewLC()
       
    32 {
       
    33     CMMAAudioPlayerFactory* pFactory =
       
    34         new(ELeave) CMMAAudioPlayerFactory();
       
    35     CleanupStack::PushL(pFactory);
       
    36     return pFactory;
       
    37 }
       
    38 
       
    39 CMMAAudioPlayerFactory::CMMAAudioPlayerFactory()
       
    40 {
       
    41 }
       
    42 
       
    43 
       
    44 CMMAAudioPlayerFactory::~CMMAAudioPlayerFactory()
       
    45 {
       
    46 }
       
    47 
       
    48 CMMAPlayer* CMMAAudioPlayerFactory::CreatePlayerL(const TDesC& aContentType)
       
    49 {
       
    50     CMMAPlayer* player = NULL;
       
    51     if (aContentType == KMMAMP3ContentType)
       
    52     {
       
    53         // If 'mp3' use 'mpeg' to create player, because audio controller
       
    54         // does not recognize mp3
       
    55         player = CMMAMMFPlayerFactory::CreatePlayerL(KMMAMPEGContentType);
       
    56     }
       
    57     else
       
    58     {
       
    59         player = CMMAMMFPlayerFactory::CreatePlayerL(aContentType);
       
    60     }
       
    61     return player;
       
    62 }
       
    63 
       
    64 CMMAPlayer* CMMAAudioPlayerFactory::CreatePlayerL(
       
    65     CMMAMMFResolver* aResolver)
       
    66 {
       
    67     CMMAAudioPlayer* player = CMMAAudioPlayer::NewLC(aResolver);
       
    68 
       
    69     CMMAAudioVolumeControl* volumeControl = CMMAAudioVolumeControl::NewL(player);
       
    70     CleanupStack::PushL(volumeControl);
       
    71     player->AddControlL(volumeControl);
       
    72     CleanupStack::Pop(volumeControl);
       
    73 
       
    74     CMMAAudioMetaDataControl* metaDataControl =
       
    75         new(ELeave) CMMAAudioMetaDataControl(player->Controller());
       
    76     CleanupStack::PushL(metaDataControl);
       
    77     player->AddControlL(metaDataControl);
       
    78     CleanupStack::Pop(metaDataControl);
       
    79 
       
    80     CMMAStopTimeControl* stopTimeControl = CMMAStopTimeControl::NewL(player);
       
    81     CleanupStack::PushL(stopTimeControl);
       
    82     player->AddControlL(stopTimeControl);
       
    83     CleanupStack::Pop(stopTimeControl);
       
    84 
       
    85     CMMAMMFRateControl* rateControl = CMMAMMFRateControl::NewL(player);
       
    86     CleanupStack::PushL(rateControl);
       
    87     player->AddControlL(rateControl);
       
    88     CleanupStack::Pop(rateControl);
       
    89 
       
    90     CleanupStack::Pop(player);
       
    91 
       
    92     return player;
       
    93 }
       
    94 
       
    95 void CMMAAudioPlayerFactory::GetSupportedContentTypesL(const TDesC& aProtocol,
       
    96         CDesC16Array& aMimeTypeArray)
       
    97 {
       
    98     // protocol is empty string all types must be returned.
       
    99     if (IsSupportedProtocolL(aProtocol) ||
       
   100             (aProtocol == KNullDesC))
       
   101     {
       
   102         // mp3 is not supported in the mmf, but support is
       
   103         // added in CreatePlayerL( const TDesC& aContentType ) method.
       
   104         aMimeTypeArray.AppendL(KMMAMP3ContentType);
       
   105 
       
   106         // all other types from mmf
       
   107         CMMAMMFPlayerFactory::GetSupportedContentTypesL(aProtocol,
       
   108                 aMimeTypeArray);
       
   109     }
       
   110 }
       
   111 
       
   112 void CMMAAudioPlayerFactory::MediaIdsL(RArray<TUid>& aMediaIds)
       
   113 {
       
   114     CleanupClosePushL(aMediaIds);
       
   115     User::LeaveIfError(aMediaIds.Append(KUidMediaTypeAudio));
       
   116     CleanupStack::Pop();
       
   117 }
       
   118 
       
   119 //  END OF FILE