src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
changeset 37 758a864f9613
parent 22 79de32ba3296
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp	Fri Sep 17 08:34:18 2010 +0300
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp	Mon Oct 04 01:19:32 2010 +0300
@@ -16,6 +16,7 @@
 
 */
 
+#include <QResource>
 #include <QUrl>
 
 #include "abstractmediaplayer.h"
@@ -216,9 +217,10 @@
     TRACE_EXIT_0();
 }
 
-void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file)
+void MMF::AbstractMediaPlayer::open()
 {
-    TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi);
+    TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi);
+    const MediaSource source = m_parent->source();
     TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
 
     close();
@@ -229,7 +231,9 @@
 
     switch (source.type()) {
     case MediaSource::LocalFile: {
-        symbianErr = openFile(file);
+        RFile *const file = m_parent->file();
+        Q_ASSERT(file);
+        symbianErr = openFile(*file);
         if (KErrNone != symbianErr)
             errorMessage = tr("Error opening file");
         break;
@@ -237,9 +241,10 @@
 
     case MediaSource::Url: {
         const QUrl url(source.url());
-
         if (url.scheme() == QLatin1String("file")) {
-            symbianErr = openFile(file);
+            RFile *const file = m_parent->file();
+            Q_ASSERT(file);
+            symbianErr = openFile(*file);
             if (KErrNone != symbianErr)
                 errorMessage = tr("Error opening file");
         } else {
@@ -251,6 +256,19 @@
         break;
     }
 
+    case MediaSource::Stream: {
+        QResource *const resource = m_parent->resource();
+        if (resource) {
+            m_buffer.Set(resource->data(), resource->size());
+            symbianErr = openDescriptor(m_buffer);
+            if (KErrNone != symbianErr)
+                errorMessage = tr("Error opening resource");
+        } else {
+            errorMessage = tr("Error opening source: resource not opened");
+        }
+        break;
+    }
+
     // Other source types are handled in MediaObject::createPlayer
 
     // Protection against adding new media types and forgetting to update this switch