BlackBerry: Fixed playback of streamed audio
authorBernd Weimer <bweimer@rim.com>
Fri, 8 Feb 2013 14:52:09 +0000 (15:52 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 12 Feb 2013 10:57:42 +0000 (11:57 +0100)
Before audio is played we always seek to position 0. Unfortunately, due
to a recent change in mmrenderer, playback stopped working for
"non-seekable" media. There is a check now, whether the media is
seekable or not.

Change-Id: Ieafd8d1364f7ce0194f4fa17d3efe894aa1b289b
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
src/plugins/blackberry/mediaservice/bbmediaplayercontrol.cpp
src/plugins/blackberry/mediaservice/bbmetadata.cpp
src/plugins/blackberry/mediaservice/bbmetadata.h

index 41d3bc4..55c8a7f 100644 (file)
@@ -304,8 +304,10 @@ void BbMediaPlayerControl::setPositionInternal(qint64 position)
     if (!m_context)
         return;
 
-    if (mmr_seek(m_context, QString::number(position).toLatin1()) != 0)
-        emitMmError("Seeking failed");
+    if (m_metaData.isSeekable()) {
+        if (mmr_seek(m_context, QString::number(position).toLatin1()) != 0)
+            emitMmError("Seeking failed");
+    }
 }
 
 void BbMediaPlayerControl::setMediaStatus(QMediaPlayer::MediaStatus status)
@@ -384,9 +386,7 @@ bool BbMediaPlayerControl::isVideoAvailable() const
 
 bool BbMediaPlayerControl::isSeekable() const
 {
-    // We can currently not get that information from the mmrenderer API. Just pretend we can seek,
-    // it will fail at runtime if we can not.
-    return true;
+    return m_metaData.isSeekable();
 }
 
 QMediaTimeRange BbMediaPlayerControl::availablePlaybackRanges() const
@@ -596,6 +596,7 @@ void BbMediaPlayerControl::updateMetaData()
     emit audioAvailableChanged(m_metaData.hasAudio());
     emit videoAvailableChanged(m_metaData.hasVideo());
     emit availablePlaybackRangesChanged(availablePlaybackRanges());
+    emit seekableChanged(m_metaData.isSeekable());
 }
 
 void BbMediaPlayerControl::emitMmError(const QString &msg)
index b34b63e..c265035 100644 (file)
@@ -57,6 +57,7 @@ static const char * heightKey = "md_video_height";
 static const char * mediaTypeKey = "md_title_mediatype";
 static const char * pixelWidthKey = "md_video_pixel_height";
 static const char * pixelHeightKey = "md_video_pixel_width";
+static const char * seekableKey = "md_title_seekable";
 
 static const int mediaTypeAudioFlag = 4;
 static const int mediaTypeVideoFlag = 2;
@@ -102,6 +103,8 @@ bool BbMetaData::parse(const QString &contextName)
                 m_pixelWidth = value.toFloat();
             else if (key == pixelHeightKey)
                 m_pixelHeight = value.toFloat();
+            else if (key == seekableKey)
+                m_seekable = !(value == QLatin1String("0"));
         }
     }
 
@@ -116,6 +119,7 @@ void BbMetaData::clear()
     m_mediaType = -1;
     m_pixelWidth = 1;
     m_pixelHeight = 1;
+    m_seekable = true;
 }
 
 qlonglong BbMetaData::duration() const
@@ -161,4 +165,9 @@ bool BbMetaData::hasAudio() const
     return (m_mediaType & mediaTypeAudioFlag);
 }
 
+bool BbMetaData::isSeekable() const
+{
+    return m_seekable;
+}
+
 QT_END_NAMESPACE
index a983a6a..e3ac9d5 100644 (file)
@@ -59,6 +59,7 @@ public:
     int width() const;
     bool hasVideo() const;
     bool hasAudio() const;
+    bool isSeekable() const;
 
 private:
     qlonglong m_duration;
@@ -67,6 +68,7 @@ private:
     int m_mediaType;
     float m_pixelWidth;
     float m_pixelHeight;
+    bool m_seekable;
 };
 
 QT_END_NAMESPACE