qtinternetradio/irqmediaplayer/src/irqmmfadapter.cpp
changeset 5 0930554dc389
parent 0 09774dfdd46b
child 14 896e9dbc5f19
equal deleted inserted replaced
3:ee64f059b8e1 5:0930554dc389
    20 #include <QStringList>
    20 #include <QStringList>
    21 #include <hxmetadatakeys.h>
    21 #include <hxmetadatakeys.h>
    22 #include "irqmetadata.h"
    22 #include "irqmetadata.h"
    23 #include "irqenums.h"
    23 #include "irqenums.h"
    24 #include "irqmmfadapter.h"
    24 #include "irqmmfadapter.h"
       
    25 #include "irqlogger.h"
    25 
    26 
    26 //Constants
    27 //Constants
    27 const TUid KUidController        = { 0x101F8514 }; // Helix Video controller UID
    28 const TUid KUidController        = { 0x101F8514 }; // Helix Video controller UID
    28 const TInt KConnectingTime       = 30*1000000;     // 30 seconds
    29 const TInt KConnectingTime       = 30*1000000;     // 30 seconds
    29 const TInt KVolumeMinPercentage  = 0;              // Minimum volume percentage
    30 const TInt KVolumeMinPercentage  = 0;              // Minimum volume percentage
    74 //  Play url via specific access point id
    75 //  Play url via specific access point id
    75 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    76 //
    77 //
    77 void IRQMMFAdapter::playStation(const QString &aUrl, int aApId)
    78 void IRQMMFAdapter::playStation(const QString &aUrl, int aApId)
    78 {
    79 {
       
    80     LOG_METHOD;
    79     TRAPD(error, playL(aUrl, aApId));
    81     TRAPD(error, playL(aUrl, aApId));
    80     if (NULL == iQMetaData)
    82     if (NULL == iQMetaData)
    81     {
    83     {
    82         emit errorOccured(EIRQErrorOutOfMemory);
    84         emit errorOccured(EIRQErrorOutOfMemory);
    83     }
    85     }
   154 //  Set volume to player
   156 //  Set volume to player
   155 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   156 //
   158 //
   157 void IRQMMFAdapter::setVolume(int aVolume)
   159 void IRQMMFAdapter::setVolume(int aVolume)
   158 {
   160 {
       
   161     LOG_METHOD;
   159     if (iVideoPlayer && iPlayState > EOpenning)
   162     if (iVideoPlayer && iPlayState > EOpenning)
   160     {
   163     {
   161         // aVolume is a percentage
   164         // aVolume is a percentage
   162         if (aVolume < KVolumeMinPercentage)
   165         if (aVolume < KVolumeMinPercentage)
   163         {
   166         {
   212 //  Called after calling CVideoPlayerUtility::OpenUrlL()
   215 //  Called after calling CVideoPlayerUtility::OpenUrlL()
   213 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   214 //
   217 //
   215 void IRQMMFAdapter::MvpuoOpenComplete(TInt aError)
   218 void IRQMMFAdapter::MvpuoOpenComplete(TInt aError)
   216 {
   219 {
       
   220     LOG_METHOD;
   217     if (KErrNone == aError)
   221     if (KErrNone == aError)
   218     {
   222     {
   219         if (NULL == iPrepareTimer)
   223         if (NULL == iPrepareTimer)
   220         {
   224         {
   221             TRAPD(error, iPrepareTimer = CPeriodic::NewL(CPeriodic::EPriorityStandard));
   225             TRAPD(error, iPrepareTimer = CPeriodic::NewL(CPeriodic::EPriorityStandard));
   253 //  are not explicitly(hxmmffourccmap.cpp), they are not retrieved here.
   257 //  are not explicitly(hxmmffourccmap.cpp), they are not retrieved here.
   254 // ---------------------------------------------------------------------------
   258 // ---------------------------------------------------------------------------
   255 //
   259 //
   256 void IRQMMFAdapter::MvpuoPrepareComplete(TInt aError)
   260 void IRQMMFAdapter::MvpuoPrepareComplete(TInt aError)
   257 {
   261 {
       
   262     LOG_METHOD;
   258     // Cancel the previous request if pending
   263     // Cancel the previous request if pending
   259     if (iPrepareTimer->IsActive())
   264     if (iPrepareTimer->IsActive())
   260     {
   265     {
   261         iPrepareTimer->Cancel();
   266         iPrepareTimer->Cancel();
   262     }
   267     }
   304 //  has no end. So it should be NEVER called.
   309 //  has no end. So it should be NEVER called.
   305 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   306 //
   311 //
   307 void IRQMMFAdapter::MvpuoPlayComplete(TInt aError)
   312 void IRQMMFAdapter::MvpuoPlayComplete(TInt aError)
   308 {
   313 {
       
   314     LOG_METHOD;
   309     if (KErrNone != aError)
   315     if (KErrNone != aError)
   310     {
   316     {
   311         emit errorOccured(EIRQPlayerErrorGeneral);
   317         emit errorOccured(EIRQPlayerErrorGeneral);
   312     }
   318     }
   313 }
   319 }
   318 //  Handle events from player.
   324 //  Handle events from player.
   319 // ---------------------------------------------------------------------------
   325 // ---------------------------------------------------------------------------
   320 //
   326 //
   321 void IRQMMFAdapter::MvpuoEvent(TMMFEvent const & aEvent)
   327 void IRQMMFAdapter::MvpuoEvent(TMMFEvent const & aEvent)
   322 {
   328 {
       
   329     LOG_METHOD;
       
   330     LOG_FORMAT( "aevent is %d", (int)aEvent);
   323     if (KMMFEventCategoryVideoPlayerGeneralError == aEvent.iEventType)
   331     if (KMMFEventCategoryVideoPlayerGeneralError == aEvent.iEventType)
   324     {
   332     {
   325         switch (aEvent.iErrorCode)
   333         switch (aEvent.iErrorCode)
   326         {
   334         {
   327             case KErrHardwareNotAvailable:
   335             case KErrHardwareNotAvailable:
   373 //  Start buffering after CVideoPlayerUtility::Play() is called
   381 //  Start buffering after CVideoPlayerUtility::Play() is called
   374 // ---------------------------------------------------------------------------
   382 // ---------------------------------------------------------------------------
   375 //
   383 //
   376 void IRQMMFAdapter::MvloLoadingStarted()
   384 void IRQMMFAdapter::MvloLoadingStarted()
   377 {
   385 {
       
   386     LOG_METHOD;
   378     // Get buffering progress and send it to application
   387     // Get buffering progress and send it to application
   379     int percentageComplete = 0;
   388     int percentageComplete = 0;
   380 
   389 
   381     TRAPD(error, iVideoPlayer->GetVideoLoadingProgressL(percentageComplete));
   390     TRAPD(error, iVideoPlayer->GetVideoLoadingProgressL(percentageComplete));
   382 
   391 
   397 //  Send 100% buffering status out
   406 //  Send 100% buffering status out
   398 // ---------------------------------------------------------------------------
   407 // ---------------------------------------------------------------------------
   399 //
   408 //
   400 void IRQMMFAdapter::MvloLoadingComplete()
   409 void IRQMMFAdapter::MvloLoadingComplete()
   401 {
   410 {
       
   411     LOG_METHOD;
   402     iPlayState = EPlaying;
   412     iPlayState = EPlaying;
   403 
   413 
   404     // Send signal to update progress, 100%
   414     // Send signal to update progress, 100%
   405     emit percentageBuffered(KLoadingCompletePercentage);
   415     emit percentageBuffered(KLoadingCompletePercentage);
   406 }
   416 }
   410 //  Get refreshed meta data according to the index
   420 //  Get refreshed meta data according to the index
   411 // ---------------------------------------------------------------------------
   421 // ---------------------------------------------------------------------------
   412 //
   422 //
   413 void IRQMMFAdapter::getRefreshedMetaDataL(TInt index)
   423 void IRQMMFAdapter::getRefreshedMetaDataL(TInt index)
   414 {
   424 {
       
   425     LOG_METHOD;
   415     if (iQMetaData)
   426     if (iQMetaData)
   416     {
   427     {
   417         CMMFMetaDataEntry* pMetadataEntry = iVideoPlayer->MetaDataEntryL(index);
   428         CMMFMetaDataEntry* pMetadataEntry = iVideoPlayer->MetaDataEntryL(index);
   418 
   429 
   419         QString entryName = QString::fromUtf16(pMetadataEntry->Name().Ptr(),
   430         QString entryName = QString::fromUtf16(pMetadataEntry->Name().Ptr(),
   504 //  Check if the preparation is complete
   515 //  Check if the preparation is complete
   505 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
   506 //
   517 //
   507 void IRQMMFAdapter::checkPrepare()
   518 void IRQMMFAdapter::checkPrepare()
   508 {
   519 {
       
   520     LOG_METHOD;
   509     if (iPrepareTimer->IsActive())
   521     if (iPrepareTimer->IsActive())
   510     {
   522     {
   511         // Cancel the previous request if pending
   523         // Cancel the previous request if pending
   512         iPrepareTimer->Cancel();
   524         iPrepareTimer->Cancel();
   513     }
   525     }