Bug 45263

Summary: Add mediaPlayerPlaybackStateChanged to MediaPlayerClient
Product: WebKit Reporter: Tor Arne Vestbø <vestbo>
Component: MediaAssignee: Tor Arne Vestbø <vestbo>
Status: RESOLVED FIXED    
Severity: Normal CC: ademar, eric.carlson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 51249    
Attachments:
Description Flags
Patch eric.carlson: review+

Description Tor Arne Vestbø 2010-09-06 06:53:00 PDT
Add mediaPlayerPlaybackStateChanged to MediaPlayerClient
Comment 1 Tor Arne Vestbø 2010-09-06 06:54:28 PDT
Created attachment 66635 [details]
Patch
Comment 2 Tor Arne Vestbø 2010-09-06 07:01:25 PDT
(In reply to comment #1)
> Created an attachment (id=66635) [details]
> Patch

Tried to keep the logic of updatePlayState() in the refactor, but wondering about if (playerPaused && couldPlayIfEnoughData()), should this check be moved out of the play/not-playing block? Or perhaps be done like this?

 if (!playerPaused)
     m_player->pause();
 
 if (couldPlayIfEnoughData())
     m_player->prepareToPlay();
Comment 3 Eric Carlson 2010-09-07 08:21:50 PDT
Comment on attachment 66635 [details]
Patch

> +        updatePlayState() is then refactored to take into account the
> +        situation where the backend is already in the correct state but
> +        WebCore is not, so that we update thee playback progress timer

Typo - "thee"

>  
> +void HTMLMediaElement::mediaPlayerPlaybackStateChanged(MediaPlayer*)
> +{
> +    beginProcessingMediaPlayerCallback();
> +    if (m_player) {
> +        if (m_player->paused())
> +            pauseInternal();
> +        else
> +            playInternal();
> +    }
> +    endProcessingMediaPlayerCallback();
> +}
> +

Might as well return early if m_player is NULL.


> +            // Set rate before calling play in case the rate was set before the media engine wasn't setup.

Old typo you might as well fix, "wasn't" should be "was".


> Tried to keep the logic of updatePlayState() in the refactor, but wondering about if (playerPaused && 
> couldPlayIfEnoughData()), should this check be moved out of the play/not-playing block? Or perhaps be 
> done like this?
>
> if (!playerPaused)
>     m_player->pause();
>
> if (couldPlayIfEnoughData())
>     m_player->prepareToPlay();

Good idea, this seems much clearer.

Thanks!

r=me
Comment 4 Tor Arne Vestbø 2010-09-08 02:22:27 PDT
Landed in http://trac.webkit.org/changeset/66961
Comment 5 Ademar Reis 2011-01-24 07:42:16 PST
Revision r66961 cherry-picked into qtwebkit-2.2 with commit b9014dd <http://gitorious.org/webkit/qtwebkit/commit/b9014dd>