src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
changeset 37 758a864f9613
parent 22 79de32ba3296
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    14 You should have received a copy of the GNU Lesser General Public License
    14 You should have received a copy of the GNU Lesser General Public License
    15 along with this library.  If not, see <http://www.gnu.org/licenses/>.
    15 along with this library.  If not, see <http://www.gnu.org/licenses/>.
    16 
    16 
    17 */
    17 */
    18 
    18 
       
    19 #include <QResource>
    19 #include <QUrl>
    20 #include <QUrl>
    20 
    21 
    21 #include "abstractmediaplayer.h"
    22 #include "abstractmediaplayer.h"
    22 #include "defs.h"
    23 #include "defs.h"
    23 #include "mediaobject.h"
    24 #include "mediaobject.h"
   214     m_positionTimer->setInterval(interval);
   215     m_positionTimer->setInterval(interval);
   215 
   216 
   216     TRACE_EXIT_0();
   217     TRACE_EXIT_0();
   217 }
   218 }
   218 
   219 
   219 void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file)
   220 void MMF::AbstractMediaPlayer::open()
   220 {
   221 {
   221     TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi);
   222     TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi);
       
   223     const MediaSource source = m_parent->source();
   222     TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
   224     TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
   223 
   225 
   224     close();
   226     close();
   225     changeState(GroundState);
   227     changeState(GroundState);
   226 
   228 
   227     TInt symbianErr = KErrNone;
   229     TInt symbianErr = KErrNone;
   228     QString errorMessage;
   230     QString errorMessage;
   229 
   231 
   230     switch (source.type()) {
   232     switch (source.type()) {
   231     case MediaSource::LocalFile: {
   233     case MediaSource::LocalFile: {
   232         symbianErr = openFile(file);
   234         RFile *const file = m_parent->file();
       
   235         Q_ASSERT(file);
       
   236         symbianErr = openFile(*file);
   233         if (KErrNone != symbianErr)
   237         if (KErrNone != symbianErr)
   234             errorMessage = tr("Error opening file");
   238             errorMessage = tr("Error opening file");
   235         break;
   239         break;
   236     }
   240     }
   237 
   241 
   238     case MediaSource::Url: {
   242     case MediaSource::Url: {
   239         const QUrl url(source.url());
   243         const QUrl url(source.url());
   240 
       
   241         if (url.scheme() == QLatin1String("file")) {
   244         if (url.scheme() == QLatin1String("file")) {
   242             symbianErr = openFile(file);
   245             RFile *const file = m_parent->file();
       
   246             Q_ASSERT(file);
       
   247             symbianErr = openFile(*file);
   243             if (KErrNone != symbianErr)
   248             if (KErrNone != symbianErr)
   244                 errorMessage = tr("Error opening file");
   249                 errorMessage = tr("Error opening file");
   245         } else {
   250         } else {
   246             symbianErr = openUrl(url.toString());
   251             symbianErr = openUrl(url.toString());
   247             if (KErrNone != symbianErr)
   252             if (KErrNone != symbianErr)
   248                 errorMessage = tr("Error opening URL");
   253                 errorMessage = tr("Error opening URL");
   249         }
   254         }
   250 
   255 
       
   256         break;
       
   257     }
       
   258 
       
   259     case MediaSource::Stream: {
       
   260         QResource *const resource = m_parent->resource();
       
   261         if (resource) {
       
   262             m_buffer.Set(resource->data(), resource->size());
       
   263             symbianErr = openDescriptor(m_buffer);
       
   264             if (KErrNone != symbianErr)
       
   265                 errorMessage = tr("Error opening resource");
       
   266         } else {
       
   267             errorMessage = tr("Error opening source: resource not opened");
       
   268         }
   251         break;
   269         break;
   252     }
   270     }
   253 
   271 
   254     // Other source types are handled in MediaObject::createPlayer
   272     // Other source types are handled in MediaObject::createPlayer
   255 
   273