src/3rdparty/phonon/mmf/mediaobject.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   237 
   237 
   238     const bool oldPlayerHasVideo = oldPlayer->hasVideo();
   238     const bool oldPlayerHasVideo = oldPlayer->hasVideo();
   239     const bool oldPlayerSeekable = oldPlayer->isSeekable();
   239     const bool oldPlayerSeekable = oldPlayer->isSeekable();
   240 
   240 
   241     Phonon::ErrorType error = NoError;
   241     Phonon::ErrorType error = NoError;
       
   242     QString errorMessage;
   242 
   243 
   243     // Determine media type
   244     // Determine media type
   244     switch (source.type()) {
   245     switch (source.type()) {
   245     case MediaSource::LocalFile:
   246     case MediaSource::LocalFile:
   246         mediaType = fileMediaType(source.fileName());
   247         mediaType = fileMediaType(source.fileName());
   251             const QUrl url(source.url());
   252             const QUrl url(source.url());
   252             if (url.scheme() == QLatin1String("file")) {
   253             if (url.scheme() == QLatin1String("file")) {
   253                 mediaType = fileMediaType(url.toLocalFile());
   254                 mediaType = fileMediaType(url.toLocalFile());
   254             }
   255             }
   255             else {
   256             else {
   256                 TRACE_0("Network streaming not supported yet");
   257                 errorMessage = QLatin1String("Network streaming not supported yet");
   257                 error = NormalError;
   258                 error = NormalError;
   258             }
   259             }
   259         }
   260         }
   260         break;
   261         break;
   261 
   262 
   284             newPlayer = new DummyPlayer(*oldPlayer);
   285             newPlayer = new DummyPlayer(*oldPlayer);
   285         } else {
   286         } else {
   286             newPlayer = new DummyPlayer();
   287             newPlayer = new DummyPlayer();
   287         }
   288         }
   288 
   289 
   289         newPlayer->setError(NormalError);
   290         error = NormalError;
       
   291         errorMessage = tr("Media type could not be determined");
   290         break;
   292         break;
   291 
   293 
   292     case MediaTypeAudio:
   294     case MediaTypeAudio:
   293         if (oldPlayer) {
   295         if (oldPlayer) {
   294             newPlayer = new AudioPlayer(*oldPlayer);
   296             newPlayer = new AudioPlayer(*oldPlayer);
   315     if (oldPlayerSeekable != isSeekable()) {
   317     if (oldPlayerSeekable != isSeekable()) {
   316         emit seekableChanged(isSeekable());
   318         emit seekableChanged(isSeekable());
   317     }
   319     }
   318 
   320 
   319     connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64)));
   321     connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64)));
   320     connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State)));
   322     connect(m_player.data(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), SIGNAL(stateChanged(Phonon::State,Phonon::State)));
   321     connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished()));
   323     connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished()));
   322     connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64)));
   324     connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64)));
   323 
   325     connect(m_player.data(), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)));
   324     if (error != NoError ) {
   326 
   325         newPlayer = new DummyPlayer();
   327     // We need to call setError() after doing the connects, otherwise the
   326         newPlayer->setError(error);
   328     // error won't be received.
       
   329     if (error != NoError) {
       
   330         Q_ASSERT(m_player);
       
   331         m_player->setError(error, errorMessage);
   327     }
   332     }
   328 
   333 
   329     TRACE_EXIT_0();
   334     TRACE_EXIT_0();
   330 }
   335 }
   331 
   336 
   351 
   356 
   352 void MMF::MediaObject::setTransitionTime(qint32 time)
   357 void MMF::MediaObject::setTransitionTime(qint32 time)
   353 {
   358 {
   354     m_player->setTransitionTime(time);
   359     m_player->setTransitionTime(time);
   355 }
   360 }
   356 
       
   357 
       
   358 //-----------------------------------------------------------------------------
       
   359 // VolumeObserver
       
   360 //-----------------------------------------------------------------------------
       
   361 
   361 
   362 void MMF::MediaObject::volumeChanged(qreal volume)
   362 void MMF::MediaObject::volumeChanged(qreal volume)
   363 {
   363 {
   364     m_player->volumeChanged(volume);
   364     m_player->volumeChanged(volume);
   365 }
   365 }