Bug 163677 - [Modern Media Controls] Media Controller: mute support
Summary: [Modern Media Controls] Media Controller: mute 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:49 PDT by Antoine Quint
Modified: 2016-10-19 23:46 PDT (History)
4 users (show)

See Also:


Attachments
Patch (41.09 KB, patch)
2016-10-19 12:34 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch for landing (45.69 KB, patch)
2016-10-19 23:10 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:49:50 PDT
We need media controller support for the mute button and when the media is muted via the media API.
Comment 1 Radar WebKit Bug Importer 2016-10-19 11:50:24 PDT
<rdar://problem/28851582>
Comment 2 Antoine Quint 2016-10-19 12:34:15 PDT
Created attachment 292094 [details]
Patch
Comment 3 Dean Jackson 2016-10-19 12:46:31 PDT
Comment on attachment 292094 [details]
Patch

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

> Source/WebCore/ChangeLog:11
> +        We introduce the MuteSupport class which brings support for muting the media
> +        by clicking on the mute button in the media controls and correctly reflecting
> +        the media's muted state should the media be muted via the media API.

I understand this is the overall goal, but it seems overkill that muting, which is just a toggle button, requires its own class. It only does two things:

1. this.mediaController.media.muted = !this.mediaController.media.muted
2. this.control.muted = this.mediaController.media.muted;

This is basically the same as the play button. And the skip back button only has one task.

Is there a way to simplify all this so you're not making new classes (and files) for all these basic tasks? Airplay, fullscreen, etc are more complicated, so that makes sense.
Comment 4 Antoine Quint 2016-10-19 13:24:05 PDT
(In reply to comment #3)
> Comment on attachment 292094 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=292094&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        We introduce the MuteSupport class which brings support for muting the media
> > +        by clicking on the mute button in the media controls and correctly reflecting
> > +        the media's muted state should the media be muted via the media API.
> 
> I understand this is the overall goal, but it seems overkill that muting,
> which is just a toggle button, requires its own class. It only does two
> things:
> 
> 1. this.mediaController.media.muted = !this.mediaController.media.muted
> 2. this.control.muted = this.mediaController.media.muted;
> 
> This is basically the same as the play button. And the skip back button only
> has one task.
> 
> Is there a way to simplify all this so you're not making new classes (and
> files) for all these basic tasks? Airplay, fullscreen, etc are more
> complicated, so that makes sense.

It's a relatively basic task and I believe it remains basic. What got the previous codebase so convoluted is how everything was lumped together, event handlers for a given event accomplishing many different things. I don't think adding a file is a big deal… although I did forget, in this patch and the previous patch, to add the file to the WebCore project and the RenderThemeMac::mediaControlsScript() method.
Comment 5 Dean Jackson 2016-10-19 13:34:58 PDT
> > I understand this is the overall goal, but it seems overkill that muting,
> > which is just a toggle button, requires its own class. It only does two
> > things:
> > 
> > 1. this.mediaController.media.muted = !this.mediaController.media.muted
> > 2. this.control.muted = this.mediaController.media.muted;
> > 
> > This is basically the same as the play button. And the skip back button only
> > has one task.
> > 
> > Is there a way to simplify all this so you're not making new classes (and
> > files) for all these basic tasks? Airplay, fullscreen, etc are more
> > complicated, so that makes sense.
> 
> It's a relatively basic task and I believe it remains basic. What got the
> previous codebase so convoluted is how everything was lumped together, event
> handlers for a given event accomplishing many different things. I don't
> think adding a file is a big deal… although I did forget, in this patch and
> the previous patch, to add the file to the WebCore project and the
> RenderThemeMac::mediaControlsScript() method.

I wonder if we can have a shortcut though. Instead of just new MuteSupport()... maybe we could have:

new ControlsSupport({
  events: "volumechange",
  handler: (event) => { this.media.muted = !this.media.muted; },
  sync: () => { this.control.muted = this.media.muted }
});

... or whatever the right names are.
Comment 6 Antoine Quint 2016-10-19 13:38:54 PDT
(In reply to comment #5)
> > > I understand this is the overall goal, but it seems overkill that muting,
> > > which is just a toggle button, requires its own class. It only does two
> > > things:
> > > 
> > > 1. this.mediaController.media.muted = !this.mediaController.media.muted
> > > 2. this.control.muted = this.mediaController.media.muted;
> > > 
> > > This is basically the same as the play button. And the skip back button only
> > > has one task.
> > > 
> > > Is there a way to simplify all this so you're not making new classes (and
> > > files) for all these basic tasks? Airplay, fullscreen, etc are more
> > > complicated, so that makes sense.
> > 
> > It's a relatively basic task and I believe it remains basic. What got the
> > previous codebase so convoluted is how everything was lumped together, event
> > handlers for a given event accomplishing many different things. I don't
> > think adding a file is a big deal… although I did forget, in this patch and
> > the previous patch, to add the file to the WebCore project and the
> > RenderThemeMac::mediaControlsScript() method.
> 
> I wonder if we can have a shortcut though. Instead of just new
> MuteSupport()... maybe we could have:
> 
> new ControlsSupport({
>   events: "volumechange",
>   handler: (event) => { this.media.muted = !this.media.muted; },
>   sync: () => { this.control.muted = this.media.muted }
> });
> 
> ... or whatever the right names are.

That's fine for this specific class, the way it is now. But I don't think it's worth it. A new file keeps things simple. Where is the code related to dealing with mute? I know: the MuteSupport file and class! All features are dealt with the same way, each with their own MediaControllerSupport class and file. It's really kind of a template, there is no real added complexity. I really wouldn't like to treat different kind of media features in different ways for the media controller, it helps keeping things in a strict framework so it doesn't become a mess like the old code did.
Comment 7 Dean Jackson 2016-10-19 13:41:48 PDT
(In reply to comment #6)

> That's fine for this specific class, the way it is now. But I don't think
> it's worth it. A new file keeps things simple. Where is the code related to
> dealing with mute? I know: the MuteSupport file and class! All features are
> dealt with the same way, each with their own MediaControllerSupport class
> and file. It's really kind of a template, there is no real added complexity.
> I really wouldn't like to treat different kind of media features in
> different ways for the media controller, it helps keeping things in a strict
> framework so it doesn't become a mess like the old code did.

OK. I think it should be MuteButtonSupport then.
Comment 8 Antoine Quint 2016-10-19 23:10:24 PDT
Created attachment 292154 [details]
Patch for landing
Comment 9 WebKit Commit Bot 2016-10-19 23:46:44 PDT
Comment on attachment 292154 [details]
Patch for landing

Clearing flags on attachment: 292154

Committed r207587: <http://trac.webkit.org/changeset/207587>
Comment 10 WebKit Commit Bot 2016-10-19 23:46:48 PDT
All reviewed patches have been landed.  Closing bug.