Changeset 65494 in webkit


Ignore:
Timestamp:
Aug 17, 2010 5:15:04 AM (14 years ago)
Author:
vestbo@webkit.org
Message:

[Qt] Pre-roll media when loading media elements

Reviewed by Antonio Gomes.

This ensures we get correct size-hints from QtMultimedia, as well as
the media states Buffering and Buffered instead of Loading and Loaded,
which we use to transition into MediaPlayer::HaveEnoughData.

  • platform/graphics/qt/MediaPlayerPrivateQt.cpp:
  • platform/graphics/qt/MediaPlayerPrivateQt.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65492 r65494  
     12010-08-17  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        [Qt] Pre-roll media when loading media elements
     6
     7        This ensures we get correct size-hints from QtMultimedia, as well as
     8        the media states Buffering and Buffered instead of Loading and Loaded,
     9        which we use to transition into MediaPlayer::HaveEnoughData.
     10
     11        * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
     12        * platform/graphics/qt/MediaPlayerPrivateQt.h:
     13
    1142010-08-16  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    215
  • trunk/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp

    r62951 r65494  
    2626#include "HTMLMediaElement.h"
    2727#include "HTMLVideoElement.h"
     28#include "NotImplemented.h"
    2829#include "TimeRanges.h"
    2930#include "Widget.h"
     
    107108    connect(m_mediaPlayer, SIGNAL(error(QMediaPlayer::Error)),
    108109            this, SLOT(handleError(QMediaPlayer::Error)));
     110    connect(m_mediaPlayer, SIGNAL(bufferStatusChanged(int)),
     111            this, SLOT(bufferStatusChanged(int)));
    109112    connect(m_mediaPlayer, SIGNAL(durationChanged(qint64)),
    110113            this, SLOT(durationChanged(qint64)));
     
    209212    m_mediaPlayer->setMuted(element->muted());
    210213    m_mediaPlayer->setVolume(static_cast<int>(element->volume() * 100.0));
     214
     215    // Setting a media source will start loading the media, but we need
     216    // to pre-roll as well to get video size-hints and buffer-status
     217    if (element->paused())
     218        m_mediaPlayer->pause();
     219    else
     220        m_mediaPlayer->play();
    211221}
    212222
     
    323333unsigned MediaPlayerPrivate::bytesLoaded() const
    324334{
    325     unsigned percentage = m_mediaPlayer->bufferStatus();
    326 
    327     if (percentage == 100) {
    328         if (m_networkState != MediaPlayer::Idle) {
    329             m_networkState = MediaPlayer::Idle;
    330             m_player->networkStateChanged();
    331         }
    332         if (m_readyState != MediaPlayer::HaveEnoughData) {
    333             m_readyState = MediaPlayer::HaveEnoughData;
    334             m_player->readyStateChanged();
    335         }
    336     }
    337 
    338335    QLatin1String bytesLoadedKey("bytes-loaded");
    339336    if (m_mediaPlayer->availableExtendedMetaData().contains(bytesLoadedKey))
    340337        return m_mediaPlayer->extendedMetaData(bytesLoadedKey).toInt();
    341338
    342     return percentage;
     339    return m_mediaPlayer->bufferStatus();
    343340}
    344341
     
    438435        m_isSeeking = false;
    439436    }
     437}
     438
     439void MediaPlayerPrivate::bufferStatusChanged(int)
     440{
     441    notImplemented();
    440442}
    441443
  • trunk/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h

    r57819 r65494  
    104104    void positionChanged(qint64);
    105105    void durationChanged(qint64);
     106    void bufferStatusChanged(int);
    106107    void volumeChanged(int);
    107108    void mutedChanged(bool);
Note: See TracChangeset for help on using the changeset viewer.