OSDN Git Service

Update Audio MediaPlayer to cope with a live stream
authorBen Murdoch <benm@google.com>
Thu, 9 Dec 2010 15:46:20 +0000 (15:46 +0000)
committerBen Murdoch <benm@google.com>
Thu, 9 Dec 2010 15:46:20 +0000 (15:46 +0000)
The Android framework gives us a duration of 0s for a live stream
so in that case tell WebCore we have an infinite duration.

Change-Id: I5caea8401406785eba61424cdb02abf9bfab0912

WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp

index c05a417..bdae711 100644 (file)
@@ -413,7 +413,16 @@ public:
     }
 
     void onPrepared(int duration, int width, int height) {
-        m_duration = duration / 1000.0f;
+        // Android media player gives us a duration of 0 for a live
+        // stream, so in that case set the real duration to infinity.
+        // We'll still be able to handle the case that we genuinely
+        // get an audio clip with a duration of 0s as we'll get the
+        // ended event when it stops playing.
+        if (duration > 0) {
+            m_duration = duration / 1000.0f;
+        } else {
+            m_duration = std::numeric_limits<float>::infinity();
+        }
         m_player->durationChanged();
         m_player->sizeChanged();
         m_player->prepareToPlay();