qtinternetradio/ui/src/irplaycontroller.cpp
changeset 12 608f67c22514
parent 8 3b03c28289e6
child 14 896e9dbc5f19
equal deleted inserted replaced
11:f683e24efca3 12:608f67c22514
    18 #include <QTimer>
    18 #include <QTimer>
    19 #ifdef Q_CC_NOKIAX86
    19 #ifdef Q_CC_NOKIAX86
    20 #include <QFile>
    20 #include <QFile>
    21 #include <QTextStream>
    21 #include <QTextStream>
    22 #endif
    22 #endif
       
    23 #ifdef HS_WIDGET_ENABLED
       
    24 #include <QSettings>
       
    25 #endif
    23 
    26 
    24 #include "irplaycontroller.h"
    27 #include "irplaycontroller.h"
    25 #include "irapplication.h"
    28 #include "irapplication.h"
    26 #include "irqmediaplayer.h"
    29 #include "irqmediaplayer.h"
    27 #include "irviewmanager.h"
    30 #include "irviewmanager.h"
    33 #include "irqsettings.h"
    36 #include "irqsettings.h"
    34 #include "irqfavoritesdb.h"
    37 #include "irqfavoritesdb.h"
    35 #include "irqstatisticsreporter.h"
    38 #include "irqstatisticsreporter.h"
    36 #include "irenummapper.h" 
    39 #include "irenummapper.h" 
    37 #include "irqlogger.h"
    40 #include "irqlogger.h"
       
    41 #ifdef HS_WIDGET_ENABLED
       
    42 #include "irservicedef.h"
       
    43 #endif
    38 
    44 
    39 #ifdef Q_CC_NOKIAX86
    45 #ifdef Q_CC_NOKIAX86
    40 void getRadioServerAddress(QString & aUrl);
    46 void getRadioServerAddress(QString & aUrl);
    41 #endif
    47 #endif
    42 
    48 
    75 #define MAP_TO_ENGINE_ConnectedFrom(ui_enum) \
    81 #define MAP_TO_ENGINE_ConnectedFrom(ui_enum) \
    76           MAP_TO_ENGINE_ENUM( IRQConnectedFrom, \
    82           MAP_TO_ENGINE_ENUM( IRQConnectedFrom, \
    77              IRQStatisticsReporter::IRConnectedFrom, \
    83              IRQStatisticsReporter::IRConnectedFrom, \
    78              ui_enum, KConnectedFromMap )                 
    84              ui_enum, KConnectedFromMap )                 
    79 
    85 
       
    86 
       
    87 static bool loadStationLogoFlag();
       
    88 static void saveStationLogoFlag(bool aIsStationLogoAvailable);
       
    89 
    80 //                                        public functions
    90 //                                        public functions
    81 
    91 
    82 /*
    92 /*
    83  * Description : constructor
    93  * Description : constructor
    84  */
    94  */
    85 IRPlayController::IRPlayController(IRApplication* aApplication) :
    95 IRPlayController::IRPlayController(IRApplication* aApplication) :
    86     iApplication(aApplication),
    96     iApplication(aApplication),
    87     iMediaPlayer(new IRQMediaPlayer()),
    97     iMediaPlayer(new IRQMediaPlayer()),
    88     iStatisticsReporter(NULL),
    98     iStatisticsReporter(NULL),
    89     iConnectedFrom(EIRQIsds),
       
    90     iGetServerResult(false),
    99     iGetServerResult(false),
    91     iNowPlayingPreset(new IRQPreset()),
   100     iNowPlayingPreset(new IRQPreset()),
    92     iNowPlayingPresetBackup(new IRQPreset()),
   101     iNowPlayingPresetBackup(new IRQPreset()),
       
   102     iConnectedFrom(EIRQIsds),
       
   103     iConnectedFromBackup(EIRQIsds),
       
   104     iStationLogoAvailable(false),
       
   105     iStationLogoAvailableBackup(false),
    93     iMetaData(NULL),
   106     iMetaData(NULL),
    94     iSongHistoryEngine(IRQSongHistoryEngine::openInstance()),
   107     iSongHistoryEngine(IRQSongHistoryEngine::openInstance()),
    95     iPlayState(EIdle),
   108     iPlayState(EIdle),
    96     iResuming(false),
   109     iResuming(false),
    97     iTryingBitrate(0),
   110     iTryingBitrate(0),
    98     iUrlArray(0),
   111     iUrlArray(0),
    99     iRealBitrate(0),
   112     iRealBitrate(0),
   100     iLastError(EIRQErrorNone),
   113     iLastError(EIRQErrorNone),
   101     iStopReason(EIRQUnknownTermination)
   114     iStopReason(EIRQUnknownTermination),
   102 {
   115     iErrorNote(NULL)
       
   116 {
       
   117     // use the last played station to initiliaze the backup value.
       
   118     // can regard the player is bootup, and initilize its LCD screen with last played station info if available.
       
   119     IRQPreset *lastPlayedPreset = iApplication->getLastPlayedStationInfo()->getLastPlayedStation();
       
   120     if (lastPlayedPreset)
       
   121     {
       
   122         *iNowPlayingPreset      =   *lastPlayedPreset;
       
   123         iLastPlayedUrl          =   getFirstTryUrl(lastPlayedPreset);
       
   124         iConnectedFrom          =   iApplication->getLastPlayedStationInfo()->connectedFrom();
       
   125         iStationLogoAvailable   =   loadStationLogoFlag();
       
   126     }
       
   127     
       
   128     if (iNowPlayingPreset->getChannelURLCount())
       
   129     {
       
   130         iPlayState = EStopped;
       
   131     }
       
   132     else
       
   133     {
       
   134         iPlayState = EIdle;
       
   135     }    
       
   136     
   103     connectSignalSlot(); 
   137     connectSignalSlot(); 
   104     iStatisticsReporter = IRQStatisticsReporter::openInstance();
   138     iStatisticsReporter = IRQStatisticsReporter::openInstance();
   105 }
   139 }
   106 
   140 
   107 /*
   141 /*
   118     delete iNowPlayingPresetBackup;
   152     delete iNowPlayingPresetBackup;
   119     iNowPlayingPresetBackup = NULL;
   153     iNowPlayingPresetBackup = NULL;
   120 
   154 
   121     delete iUrlArray;
   155     delete iUrlArray;
   122     iUrlArray = NULL;
   156     iUrlArray = NULL;
   123 
   157     
       
   158     delete iErrorNote;
       
   159     iErrorNote = NULL;
       
   160 
       
   161     saveStationLogoFlag(iStationLogoAvailable);
       
   162 	
   124     if (iSongHistoryEngine)
   163     if (iSongHistoryEngine)
   125     {
   164     {
   126         iSongHistoryEngine->closeInstance();
   165         iSongHistoryEngine->closeInstance();
   127         iSongHistoryEngine = NULL;
   166         iSongHistoryEngine = NULL;
   128     }
   167     }
   137  * Description : connect to a channel specified by aPreset.
   176  * Description : connect to a channel specified by aPreset.
   138  * Parameters  : aPreset : the preset of the channel
   177  * Parameters  : aPreset : the preset of the channel
   139  */
   178  */
   140 void IRPlayController::connectToChannel(IRQPreset *aPreset, IRQConnectedFrom aConnectedFrom)
   179 void IRPlayController::connectToChannel(IRQPreset *aPreset, IRQConnectedFrom aConnectedFrom)
   141 {
   180 {
   142     iConnectedFrom = aConnectedFrom;
       
   143     if (!aPreset)
   181     if (!aPreset)
   144     {
   182     {
   145         return;
   183         return;
   146     }
   184     }
   147 
   185 
   148     if (iMediaPlayer)
   186     if (iMediaPlayer)
   149     {
   187     {       
   150         // sort the URL by ascending order and get all available rates.
   188         QString firstTryUrl = getFirstTryUrl(aPreset);
   151         // iAvailableBitrate is cleared in getAvailableBitrates().
   189         if (firstTryUrl.isEmpty())
   152         aPreset->sortURLArray();
       
   153         aPreset->getAvailableBitrates(iAvailableBitrate);
       
   154         if (iAvailableBitrate.count() == 0)
       
   155         {
   190         {
   156             return;
   191             return;
   157         }
   192         }
   158         
   193         
   159         int selectedBitRate = 0;
   194         *iNowPlayingPresetBackup = *iNowPlayingPreset;         
   160         IRQPreferredQuality preferredQuality = iApplication->getSettings()->getPreferredQuality();
   195         iLastPlayedUrlBackup = iLastPlayedUrl;
   161         switch(preferredQuality)
   196         iConnectedFromBackup = iConnectedFrom;
   162         {
       
   163             case EIRQStandardQuality:
       
   164                 selectedBitRate = iAvailableBitrate.first();
       
   165                 break;
       
   166             case EIRQHighQuality:
       
   167                 selectedBitRate = iAvailableBitrate.last();
       
   168                 break;
       
   169             default:
       
   170                 selectedBitRate = iAvailableBitrate.first();
       
   171                 break;
       
   172         }
       
   173 
       
   174         // get URL to play
       
   175         iTryingBitrate = selectedBitRate;
       
   176         
   197         
   177         //reserve the info in nowplay view
   198         *iNowPlayingPreset = *aPreset;           
   178         *iNowPlayingPresetBackup = *iNowPlayingPreset;
   199         iLastPlayedUrl = firstTryUrl;
   179         *iNowPlayingPreset = *aPreset;
   200         iConnectedFrom = aConnectedFrom;
   180         
   201         iResuming = false;
   181         delete iUrlArray;
   202         doPlay(iLastPlayedUrl);
   182         iUrlArray = NULL;
   203     }
   183         iUrlArray = iNowPlayingPreset->getURLsForBitrate(selectedBitRate);
   204 }
   184         if (iUrlArray)
   205 
   185         {
   206 QString IRPlayController::getFirstTryUrl(IRQPreset *aPreset)
   186             QString url = iUrlArray->at(0);
   207 {
       
   208     QString firstTryUrl;
       
   209     // sort the URL by ascending order and get all available rates.
       
   210     // iAvailableBitrate is cleared in getAvailableBitrates().
       
   211     aPreset->sortURLArray();
       
   212     aPreset->getAvailableBitrates(iAvailableBitrate);
       
   213     if (iAvailableBitrate.count() == 0)
       
   214     {
       
   215         return firstTryUrl;
       
   216     }
       
   217     
       
   218     int selectedBitRate = 0;
       
   219     IRQPreferredQuality preferredQuality = iApplication->getSettings()->getPreferredQuality();
       
   220     switch(preferredQuality)
       
   221     {
       
   222         case EIRQStandardQuality:
       
   223             selectedBitRate = iAvailableBitrate.first();
       
   224             break;
       
   225         case EIRQHighQuality:
       
   226             selectedBitRate = iAvailableBitrate.last();
       
   227             break;
       
   228         default:
       
   229             selectedBitRate = iAvailableBitrate.first();
       
   230             break;
       
   231     }
       
   232 
       
   233     // get URL to play
       
   234     iTryingBitrate = selectedBitRate;
       
   235     
       
   236     delete iUrlArray;
       
   237     iUrlArray = NULL;
       
   238     iUrlArray = aPreset->getURLsForBitrate(selectedBitRate);
       
   239     if (iUrlArray)
       
   240     {
       
   241         firstTryUrl = iUrlArray->at(0);
   187 #ifdef Q_CC_NOKIAX86
   242 #ifdef Q_CC_NOKIAX86
   188             if (iLastPlayedChannelName != aPreset->name)
   243         firstTryUrl = "http://172.28.182.59:8000";
   189             {
   244         getRadioServerAddress(firstTryUrl);
   190                 emit initializeLogo();
       
   191             }
       
   192             url = "http://172.28.205.171:8000";
       
   193             getRadioServerAddress(url);
       
   194             iLastPlayedChannelName = aPreset->name;
       
   195 #else
       
   196             if (iLastPlayedUrl != iUrlArray->at(0))
       
   197             {
       
   198                 emit initializeLogo();
       
   199             }
       
   200 #endif
   245 #endif
   201             //reserve the info in nowplay view
   246     }
   202             iLastPlayedUrlBackup = iLastPlayedUrl;
   247     
   203             iLastPlayedUrl = url;
   248     return firstTryUrl;
   204             iResuming = false;
       
   205             doPlay(url);
       
   206         }
       
   207     }
       
   208 }
   249 }
   209 
   250 
   210 /*
   251 /*
   211  * Description : RESUME playing after play is stopped.
   252  * Description : RESUME playing after play is stopped.
   212  *               Use the last played url as station's url.
   253  *               Use the last played url as station's url.
   230 /*
   271 /*
   231  * Description : stop playing
   272  * Description : stop playing
   232  */
   273  */
   233 void IRPlayController::stop(IRQTerminatedType aStopReason)
   274 void IRPlayController::stop(IRQTerminatedType aStopReason)
   234 {
   275 {
   235     qDebug("IRPlayController::stop, Entering, aStopReason=%d", aStopReason);
   276     qDebug("IRPlayController::stop, Entering, aStopReason=%d", aStopReason);        
   236     if (iMediaPlayer)
   277     
   237     {
   278     switch (iPlayState)
   238         iMediaPlayer->disableStereoEffect();
   279     {   
   239 
   280         case EPlaying:
   240         iMediaPlayer->stop();
   281             iPlayState = EStopped; 
   241 
       
   242         if (EPlaying == iPlayState)
       
   243         {
       
   244             iStopReason = aStopReason;
   282             iStopReason = aStopReason;
       
   283             if (iMediaPlayer)
       
   284             {
       
   285                 iMediaPlayer->disableStereoEffect();
       
   286                 iMediaPlayer->stop(); 
       
   287             }
   245             // playingStarted is emitted while iPlaying is set to true,
   288             // playingStarted is emitted while iPlaying is set to true,
   246             // so when stop() is called and iPlaying is true, playingStopped
   289             // so when stop() is called and iPlaying is true, playingStopped
   247             // should be emitted.
   290             // should be emitted.
   248             qDebug("IRPlayController::stop, emit playingStopped()");
   291             qDebug("IRPlayController::stop, emit playingStopped()");             
   249             emit playingStopped();
   292             emit playingStopped();              
   250         }
   293             break;
   251         iPlayState = EStopped;
   294 
       
   295 #ifdef HS_WIDGET_ENABLED			
       
   296         case EConnecting:     
       
   297             // No need to restore because when connecting occurs, because the connectToChannel() has NOT been invoked yet. 
       
   298             // Only need to reset the player state                  
       
   299             if (iNowPlayingPreset->getChannelURLCount())
       
   300             {
       
   301                 iPlayState = EStopped;
       
   302             }
       
   303             else
       
   304             {
       
   305                 iPlayState = EIdle;
       
   306             }
       
   307             
       
   308             iStopReason = aStopReason;  
       
   309             
       
   310             // Only need to restore the station logo flag since we may force it to be false when connecting started.   
       
   311             // force logo to be default when current view is NOT nowplaying view && is not resuming (start playing a different station.) 
       
   312             if (EIRView_PlayingView != iApplication->getViewManager()->currentViewId()
       
   313                 && iConnectingStationName != iNowPlayingPreset->name)
       
   314             {
       
   315                 iStationLogoAvailable = iStationLogoAvailableBackup;
       
   316                 emit stationLogoUpdated(iStationLogoAvailable);             
       
   317             }                      
       
   318             emit connectingCancelled(iNowPlayingPreset->name);
       
   319             break;
       
   320 #endif
       
   321             
       
   322         case EBuffering:
       
   323             if (iMediaPlayer)
       
   324             {
       
   325                 iMediaPlayer->disableStereoEffect();
       
   326                 iMediaPlayer->stop(); 
       
   327             }
       
   328             // when player is forced to stop in bufferring state, we have to revert to backup preset.
       
   329             // only with exception when current view is nowplaying view.
       
   330             // in IR case, user can only stay in nowplaying view when buffering:
       
   331             // 1. starging view is now playing view; 2. open a pls file with only one url
       
   332             if (EIRView_PlayingView != iApplication->getViewManager()->currentViewId())
       
   333             {
       
   334                 iLastPlayedUrl        = iLastPlayedUrlBackup;
       
   335                 *iNowPlayingPreset    = *iNowPlayingPresetBackup;
       
   336                 iConnectedFrom        = iConnectedFromBackup;               
       
   337             }
       
   338             
       
   339             if (iNowPlayingPreset->getChannelURLCount())
       
   340             {
       
   341                 iPlayState = EStopped;
       
   342             }
       
   343             else
       
   344             {
       
   345                 iPlayState = EIdle;
       
   346             }
       
   347             
       
   348             iStopReason = aStopReason;
       
   349                         
       
   350 #ifdef HS_WIDGET_ENABLED            
       
   351             // Need to restore the station logo flag since we may force it to be false when buffering started.  
       
   352             // force logo to be default when current view is NOT nowplaying view && is not resuming (start playing a different station.) 
       
   353             if (EIRView_PlayingView != iApplication->getViewManager()->currentViewId()
       
   354                 && !iResuming)
       
   355             {
       
   356                 iStationLogoAvailable = iStationLogoAvailableBackup;
       
   357                 emit stationLogoUpdated(iStationLogoAvailable);             
       
   358             }                         
       
   359             emit bufferingCancelled(iNowPlayingPreset->name);
       
   360 #endif
       
   361             break;
       
   362 		
       
   363 			
       
   364         case EIdle:
       
   365         case EStopped:		
       
   366         default:              
       
   367             break;
   252     }
   368     }
   253 	endSession(aStopReason);
   369 	endSession(aStopReason);
   254 	qDebug("IRPlayController::stop, Exiting");
   370 	qDebug("IRPlayController::stop, Exiting");
   255 }
   371 }
   256 
   372 
   295     if (EPlaying == iPlayState)
   411     if (EPlaying == iPlayState)
   296     {
   412     {
   297         iMediaPlayer->setVolume(aVolume);
   413         iMediaPlayer->setVolume(aVolume);
   298     }
   414     }
   299     iApplication->getSettings()->setVolumeSetting(aVolume);
   415     iApplication->getSettings()->setVolumeSetting(aVolume);
       
   416 }
       
   417 
       
   418 #ifdef HS_WIDGET_ENABLED
       
   419 void IRPlayController::setConnectingStationName(const QString &aStationName, bool aForceConnecting)
       
   420 {
       
   421     iConnectingStationName = aStationName;
       
   422     if (aForceConnecting
       
   423          || !iApplication->getNetworkController()->getNetworkStatus())
       
   424     {
       
   425         LOG_FORMAT("IRPlayController::setConnectingStationName, the station name is %s", STRING2CHAR(aStationName));
       
   426         iPlayState = EConnecting;   
       
   427         
       
   428         // force logo to be default when current view is NOT nowplaying view && is not resuming (start playing a different station.) 
       
   429         if (EIRView_PlayingView != iApplication->getViewManager()->currentViewId()
       
   430             && iConnectingStationName != iNowPlayingPreset->name)
       
   431         {
       
   432             emitStationLogoUpdated(false);
       
   433         }        
       
   434         emit connectingStarted(aStationName);
       
   435     }
       
   436 }
       
   437 
       
   438 QString IRPlayController::getConnectingStationName() const
       
   439 {
       
   440     return iConnectingStationName;
       
   441 }
       
   442 
       
   443 void IRPlayController::reloadNowplayingPreset(IRQPreset *aPreset, bool aIsLogoAvailable, IRQConnectedFrom aConnectedFrom)
       
   444 {
       
   445     if (aPreset)
       
   446     {
       
   447         *iNowPlayingPreset      =   *aPreset;
       
   448         iLastPlayedUrl          =   getFirstTryUrl(aPreset);
       
   449         iConnectedFrom          =   aConnectedFrom;
       
   450         iStationLogoAvailable   =   aIsLogoAvailable;
       
   451     }
       
   452     
       
   453     if (iNowPlayingPreset->getChannelURLCount())
       
   454     {
       
   455         iPlayState = EStopped;
       
   456     }
       
   457     else
       
   458     {
       
   459         iPlayState = EIdle;
       
   460     }     
       
   461 }
       
   462 
       
   463 bool IRPlayController::isStationLogoAvailable() const
       
   464 {
       
   465     return iStationLogoAvailable;
       
   466 }
       
   467 
       
   468 void IRPlayController::emitStationLogoUpdated(bool aIsLogoAvailable)
       
   469 {
       
   470     iStationLogoAvailableBackup = iStationLogoAvailable;
       
   471     iStationLogoAvailable = aIsLogoAvailable;
       
   472     emit stationLogoUpdated(iStationLogoAvailable);
       
   473 }
       
   474 
       
   475 bool loadStationLogoFlag()
       
   476 {
       
   477     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
       
   478     return settings.value(KIrSettingStationLogoAvailable,false).toBool();
       
   479 }
       
   480 
       
   481 #endif
       
   482 
       
   483 IRPlayController::EPlayState IRPlayController::state() const
       
   484 {
       
   485     return iPlayState;
   300 }
   486 }
   301 
   487 
   302 /*
   488 /*
   303  * Description : return the flag of playing state
   489  * Description : return the flag of playing state
   304  * Return      : true  : playing is ongoing
   490  * Return      : true  : playing is ongoing
   426         }
   612         }
   427 		
   613 		
   428         // if there's NO other URL to try, show warning.
   614         // if there's NO other URL to try, show warning.
   429         if (iNowPlayingPreset->getChannelURLCount() == 1)
   615         if (iNowPlayingPreset->getChannelURLCount() == 1)
   430         {
   616         {
   431             //here recover info in nowplay view, only for cases:
       
   432             //1/a channel has one url. 2/ invoked by "go to station" view.
       
   433             //if a channel has more than one url, here can't be reached.
       
   434             iLastPlayedUrl = iLastPlayedUrlBackup;
       
   435             *iNowPlayingPreset = *iNowPlayingPresetBackup;
       
   436 		    stop(EIRQNoConnectionToServer);
   617 		    stop(EIRQNoConnectionToServer);
   437             break;
   618             break;
   438         }
   619         }
   439 
   620 
   440         if (iResuming)
   621         if (iResuming)
   472         stop(EIRQUnknownTermination);
   653         stop(EIRQUnknownTermination);
   473         break;
   654         break;
   474     }
   655     }
   475 
   656 
   476     iApplication->stopLoadingAnimation();
   657     iApplication->stopLoadingAnimation();
   477     createNote();
   658     popupNote();
   478     qDebug("IRPlayController::handleError(), Exiting");
   659     qDebug("IRPlayController::handleError(), Exiting");
   479 }
   660 }
   480 
   661 
   481 /*
   662 /*
   482  * Description : buffering process has updated, change the display of buffering dialog.
   663  * Description : buffering process has updated, change the display of buffering dialog.
   486  */
   667  */
   487 void IRPlayController::updateProgress(int aProgress)
   668 void IRPlayController::updateProgress(int aProgress)
   488 {
   669 {
   489     if (100 == aProgress)
   670     if (100 == aProgress)
   490     {
   671     {
       
   672         //updateProgress(100) sometimes can be called more than one time, to improve performance,
       
   673         //we only need to do the following work once.        
       
   674         if (EPlaying == iPlayState)
       
   675         {
       
   676             iApplication->stopLoadingAnimation();
       
   677             return;
       
   678         }
       
   679         
       
   680         iPlayState = EPlaying;
   491         iApplication->stopLoadingAnimation();
   681         iApplication->stopLoadingAnimation();
   492 
   682 
   493         //updateProgress(100) sometimes can be called more than one time, to improve performance,
   683         iApplication->getViewManager()->activateView(EIRView_PlayingView);
   494         //we only need to do the following work once.
   684 
   495         if (EBuffering == iPlayState)
   685         //update last played station
   496         {
   686         IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();
   497             iApplication->getViewManager()->activateView(EIRView_PlayingView);
   687         lastPlayedStationInfo->updateLastPlayedStation(iNowPlayingPreset,iConnectedFrom);
   498             iPlayState = EPlaying;
   688         lastPlayedStationInfo->commitLastPlayedStation();
   499 
   689 
   500             //update last played station
   690         //increase the played times of current preset
   501             IRLastPlayedStationInfo *lastPlayedStationInfo = iApplication->getLastPlayedStationInfo();
   691         iApplication->getFavoritesDB()->increasePlayedTimes(*iNowPlayingPreset);
   502             lastPlayedStationInfo->updateLastPlayedStation(iNowPlayingPreset,iConnectedFrom);
   692 
   503             lastPlayedStationInfo->commitLastPlayedStation();
   693         emit playingStarted();
   504 
   694 
   505             //increase the played times of current preset
   695         // if the metadata is available, show it.
   506             iApplication->getFavoritesDB()->increasePlayedTimes(*iNowPlayingPreset);
   696         emit metaDataAvailable(iMetaData);
   507 
   697 
   508             emit playingStarted();
   698         // Save the station information to database
   509 
   699         IRQMetaData tmpMetaData;
   510             // if the metadata is available, show it.
   700         tmpMetaData.setBitrate(iRealBitrate);
   511             emit metaDataAvailable(iMetaData);
   701         tmpMetaData.setStreamUrl(iLastPlayedUrl);
   512 
   702         iSongHistoryEngine->handleMetaDataReceived(tmpMetaData, *iNowPlayingPreset);
   513             // Save the station information to database
   703         // open stereo defaultly
   514             IRQMetaData tmpMetaData;
   704         iMediaPlayer->enableStereoEffect();
   515             tmpMetaData.setBitrate(iRealBitrate);
       
   516             tmpMetaData.setStreamUrl(iLastPlayedUrl);
       
   517             iSongHistoryEngine->handleMetaDataReceived(tmpMetaData, *iNowPlayingPreset);
       
   518             // open stereo defaultly
       
   519             iMediaPlayer->enableStereoEffect();
       
   520         }
       
   521     }
   705     }
   522 }
   706 }
   523 
   707 
   524 /*
   708 /*
   525  * Description : get volume value from application setting. media player use the value
   709  * Description : get volume value from application setting. media player use the value
   569 
   753 
   570 /*
   754 /*
   571  * Description : show a note to user to inform that error occured.
   755  * Description : show a note to user to inform that error occured.
   572  *                
   756  *                
   573  */
   757  */
   574 void IRPlayController::createNote(const QString &aNote)
   758 void IRPlayController::popupNote(const QString &aNote)
   575 {
   759 {
   576     HbMessageBox::warning(aNote, (QObject*)NULL, NULL);
   760     if (NULL == iErrorNote)
       
   761     {
       
   762         iErrorNote = new HbMessageBox(HbMessageBox::MessageTypeWarning);
       
   763         iErrorNote->setModal(true);
       
   764         iErrorNote->setTimeout(HbPopup::StandardTimeout);
       
   765     }
       
   766     
       
   767     iErrorNote->setText(aNote);
       
   768     // if there is already on error note showing, only change the text 
       
   769     if (!iErrorNote->isVisible())
       
   770     {
       
   771         iErrorNote->show();
       
   772     }
   577 }
   773 }
   578 
   774 
   579 /*
   775 /*
   580  * Description : establish the signal&slot connection between media player and play controller
   776  * Description : establish the signal&slot connection between media player and play controller
   581  */
   777  */
   668     unsigned long apId = 0;
   864     unsigned long apId = 0;
   669     iApplication->getNetworkController()->getIAPId(apId);
   865     iApplication->getNetworkController()->getIAPId(apId);
   670     qDebug("IRPlayController::doPlay, access point : %d", apId);
   866     qDebug("IRPlayController::doPlay, access point : %d", apId);
   671     iMediaPlayer->playStation(aUrl, apId);
   867     iMediaPlayer->playStation(aUrl, apId);
   672     iPlayState = EBuffering;
   868     iPlayState = EBuffering;
       
   869 #ifdef HS_WIDGET_ENABLED	
       
   870     // force logo to be default when current view is NOT nowplaying view && is not resuming (start playing a different station.) 
       
   871     if (EIRView_PlayingView != iApplication->getViewManager()->currentViewId()
       
   872         && !iResuming)
       
   873     {
       
   874         emitStationLogoUpdated(false);             
       
   875     }   
       
   876     emit bufferingStarted(iNowPlayingPreset->name);
       
   877 #endif	
   673     startSession();
   878     startSession();
   674     iApplication->startLoadingAnimation(this, SLOT(cancelBuffering()));
   879     iApplication->startLoadingAnimation(this, SLOT(cancelBuffering()));
   675 }
   880 }
   676 
   881 
   677 /*
   882 /*
   697 int IRPlayController::bitrateTrying() const
   902 int IRPlayController::bitrateTrying() const
   698 {
   903 {
   699     return iTryingBitrate;
   904     return iTryingBitrate;
   700 }
   905 }
   701 #endif 
   906 #endif 
       
   907 
       
   908 void saveStationLogoFlag(bool aIsStationLogoAvailable)
       
   909 {
       
   910     QSettings settings(KIrSettingOrganization, KIrSettingApplication);
       
   911     QVariant data(QVariant::Bool);
       
   912     data.setValue(aIsStationLogoAvailable);
       
   913     settings.setValue(KIrSettingStationLogoAvailable,data);
       
   914 }
   702 
   915 
   703 //get IP address configuration of test radio server
   916 //get IP address configuration of test radio server
   704 #ifdef Q_CC_NOKIAX86
   917 #ifdef Q_CC_NOKIAX86
   705 void getRadioServerAddress(QString & aUrl)
   918 void getRadioServerAddress(QString & aUrl)
   706 {
   919 {