Bug 163678 - [Modern Media Controls] Media Controller: playback support
Summary: [Modern Media Controls] Media Controller: playback support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Safari 10
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-10-19 11:51 PDT by Antoine Quint
Modified: 2016-10-26 13:28 PDT (History)
3 users (show)

See Also:


Attachments
Patch (47.03 KB, patch)
2016-10-20 03:31 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch for landing (51.69 KB, patch)
2016-10-26 12:42 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2016-10-19 11:51:16 PDT
We need media controller support for the play/pause button and when the media is played and paused via the media API.
Comment 1 Antoine Quint 2016-10-19 11:51:38 PDT
<rdar://problem/27989479>
Comment 2 Antoine Quint 2016-10-20 03:31:07 PDT
Created attachment 292164 [details]
Patch
Comment 3 Dean Jackson 2016-10-20 18:56:09 PDT
Comment on attachment 292164 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=292164&action=review

> Source/WebCore/Modules/modern-media-controls/media/playback-support.js:54
> +class PlaybackSupport extends MediaControllerSupport
> +{
> +
> +    // Protected
> +
> +    get control()
> +    {
> +        return this.mediaController.controls.playPauseButton;
> +    }
> +
> +    get mediaEvents()
> +    {
> +        return ["play", "pause"];
> +    }
> +
> +    buttonWasClicked(control)
> +    {
> +        const media = this.mediaController.media;
> +        if (media.paused)
> +            media.play();
> +        else
> +            media.pause();
> +    }
> +
> +    syncControl()
> +    {
> +        this.control.playing = !this.mediaController.media.paused;
> +    }
> +

This is another example of a super simple Support class. I'm fairly worried about how confusing the end result of the approach will be. When it was in one huge file, you could at least search for the eventListener that was added to the play button.
Comment 4 Antoine Quint 2016-10-21 01:23:37 PDT
(In reply to comment #3)
> Comment on attachment 292164 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=292164&action=review
> 
> > Source/WebCore/Modules/modern-media-controls/media/playback-support.js:54
> > +class PlaybackSupport extends MediaControllerSupport
> > +{
> > +
> > +    // Protected
> > +
> > +    get control()
> > +    {
> > +        return this.mediaController.controls.playPauseButton;
> > +    }
> > +
> > +    get mediaEvents()
> > +    {
> > +        return ["play", "pause"];
> > +    }
> > +
> > +    buttonWasClicked(control)
> > +    {
> > +        const media = this.mediaController.media;
> > +        if (media.paused)
> > +            media.play();
> > +        else
> > +            media.pause();
> > +    }
> > +
> > +    syncControl()
> > +    {
> > +        this.control.playing = !this.mediaController.media.paused;
> > +    }
> > +
> 
> This is another example of a super simple Support class. I'm fairly worried
> about how confusing the end result of the approach will be. When it was in
> one huge file, you could at least search for the eventListener that was
> added to the play button.

If you're searching for `playPauseButton`, you'll easy find this code just like you would have found it in a monolithic source file. But at least here the code related to the behaviour of the play/pause button is clearly contained.
Comment 5 Antoine Quint 2016-10-26 12:42:21 PDT
Created attachment 292954 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2016-10-26 13:28:13 PDT
The commit-queue encountered the following flaky tests while processing attachment 292954 [details]:

http/tests/security/svg-image-with-css-cross-domain.html bug 164029 (author: sabouhallawa@apple.com)
The commit-queue is continuing to process your patch.
Comment 7 WebKit Commit Bot 2016-10-26 13:28:51 PDT
Comment on attachment 292954 [details]
Patch for landing

Clearing flags on attachment: 292954

Committed r207909: <http://trac.webkit.org/changeset/207909>
Comment 8 WebKit Commit Bot 2016-10-26 13:28:54 PDT
All reviewed patches have been landed.  Closing bug.