Closed Bug 689374 Opened 13 years ago Closed 6 years ago

Specialized HTML5 audio controls for small-dimensions

Categories

(Toolkit :: Video/Audio Controls, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jaws, Unassigned, Mentored)

References

Details

(Whiteboard: [lang=js])

Attachments

(15 obsolete files)

Similar to bug 462117, we need to have a way to either reduce the amount of visible controls or restyle them to fit smaller dimensions when HTML5 <audio> tags have widths & heights that don't fit the default sizes.
Whiteboard: [good first bug][mentor=jwein]
This bug is similar to bug 462117, except we can't base our calculations off of |videoHeight| and |videoWidth|. We should be able to use much of the same code, but will just have to depend on different width/height for our calculations.
I've created a test page by modifying a test page from the earlier bug ( http://panuhorsmalahti.fi/audiodimensions.html ). I'll take a shot at creating a patch later.
(In reply to Panu Horsmalahti from comment #2)
> I've created a test page by modifying a test page from the earlier bug (
> http://panuhorsmalahti.fi/audiodimensions.html ). I'll take a shot at
> creating a patch later.

Cool, please let me know if there is anything I can do to help you out with getting started.
The changes necessary to fix this bug should be made in /toolkit/content/widgets/videocontrols.xml
Whiteboard: [good first bug][mentor=jwein] → [good first bug][mentor=jwein][lang=js]
If nobody is currently working on this, I can pick it up.
Go for it!
Assignee: nobody → bhatnagar.anurag
Status: NEW → ASSIGNED
Whiteboard: [good first bug][mentor=jwein][lang=js] → [good first bug][mentor=jaws][lang=js]
Assignee: bhatnagar.anurag → nobody
Status: ASSIGNED → NEW
Whiteboard: [good first bug][mentor=jaws][lang=js] → [mentor=jaws][lang=js]
For a project in our Software Engineering class, we would like to work on this bug. Thank you!
Great! Let me know of any questions you may have :)
Assignee: nobody → dragonfiredtb
Status: NEW → ASSIGNED
Hey Jared, I dont know if Bao mentioned to you that I'm his partner for the Software Engineering class. I will take a look at this bug and let you know if I have any questions.
Jared, So for the bug, the main issue is adjusting the visible controls to fit within the <audio> tags right? If so, the changes im proposing is to write a javascript function that can get the height and width and compare it to the default one and scale the controls accordingly with the height and width.
What do you mean by "the default one"? Basically, the buttons in the audio controls have a fixed width. The scrubber is the only flexible width item in the controls and that grows to consume the available space.

You can look at the code that was changed for bug 462117, https://hg.mozilla.org/mozilla-central/rev/5a45436b3c18, for an example.
what i meant by the default one is the width and height for the <audio> tags. Thank you for the reference to bug 462117. which url link should I look at to see where the bug happens?
You should be able to use http://panuhorsmalahti.fi/audiodimensions.html for testing.
ok thank you for the link. I'll start working on it soon and make the changes accordingly. Thanks.
Hey Jared, i compared the submitted code from bug 462117 and see the changes inside videocontrols.css and videocontrols.xml. I was wondering what parts of the code I should focus on so that the visible controls fit the dimensions?
Flags: needinfo?(jaws)
Tests should include how text from the <track> element appears from bug 833385.
Attachment #754684 - Flags: review?(jaws)
Flags: needinfo?(jaws)
Comment on attachment 754684 [details] [diff] [review]
First attempt at fixing the audio controls

This attachment doesn't show what has been added, removed, or changed.

You'll have to resubmit the patch following the steps that are described here: https://developer.mozilla.org/en-US/docs/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3F
Attachment #754684 - Flags: review?(jaws)
Attachment #754684 - Attachment is obsolete: true
Attachment #754890 - Flags: review?(jaws)
Comment on attachment 754890 [details] [diff] [review]
First attempt at fixing the audio controls

Review of attachment 754890 [details] [diff] [review]:
-----------------------------------------------------------------

This patch includes the code changes from bug 730626. Please separate these changes. This patch also changed a bunch of lines from having leading space characters to leading tab characters.

Please fix up these two issues and reupload.
Attachment #754890 - Flags: review?(jaws)
Attachment #754890 - Attachment is obsolete: true
Attachment #755188 - Flags: review?(jaws)
Comment on attachment 755188 [details] [diff] [review]
First attempt at fixing the audio controls

Review of attachment 755188 [details] [diff] [review]:
-----------------------------------------------------------------

This patch is based off a non-existent revision. Can you try getting a new clone of the mozilla-central tree and making your changes again?
Attachment #755188 - Flags: review?(jaws) → review-
Attachment #755188 - Attachment is obsolete: true
Attachment #755554 - Flags: review?(jaws)
Comment on attachment 755554 [details] [diff] [review]
First attempt at fixing the audio controls

Review of attachment 755554 [details] [diff] [review]:
-----------------------------------------------------------------

Much of this code is duplicated in the two cases. It seems that the only part that needs to be handled separately is calculating the height and width of the media element.

::: toolkit/content/widgets/videocontrols.xml
@@ +1337,5 @@
>                  _overlayPlayButtonWidth : 64,
>                  adjustControlSize : function adjustControlSize() {
> +                    if (this.isAudioOnly){
> +                        let audioHeight = this.video.clientHeight;
> +                        let audioWidth = this.video.clientWidth;

What values do audioHeight and audioWidth have?

If this patch works, then we can probably change nothing except removing the "if (this.isAudioOnly) return" code and renaming videoHeight and videoWidth to mediaHeight and mediaWidth, respectively.
Attachment #755554 - Flags: review?(jaws)
Attachment #755554 - Attachment is obsolete: true
Attachment #755710 - Flags: review?(jaws)
What values do mediaWidth and mediaHeight have for <audio> elements? What happens when the page doesn't specify a size for the element?
Flags: needinfo?(seanchen)
Attached patch Added console.log for debugging. (obsolete) — Splinter Review
Attachment #755710 - Attachment is obsolete: true
Attachment #755710 - Flags: review?(jaws)
Attachment #757011 - Flags: feedback?(jaws)
Flags: needinfo?(seanchen)
Comment on attachment 757011 [details] [diff] [review]
Added console.log for debugging.

Review of attachment 757011 [details] [diff] [review]:
-----------------------------------------------------------------

Hi Sean, we don't need to check in these log statements. Do you have answers to the previous questions?
Attachment #757011 - Flags: feedback?(jaws)
I cannot see the values for mediaWidth and mediaHeight through console.log. Where would I be able to see the results from console.log? For the second question, are you talking about mediaWidth and mediaHeight when they don't specify a size?
(In reply to Sean Chen from comment #29)
> I cannot see the values for mediaWidth and mediaHeight through console.log.
> Where would I be able to see the results from console.log?

We talked about this over IRC.

> For the second
> question, are you talking about mediaWidth and mediaHeight when they don't
> specify a size?

Yes, when a webpage is simply:
<html><body><audio src="foo.mp4" controls/></body></html>
Here are the results I have for mediaWidth and mediaHeight for the audio elements.

Media Height: 0 Media Width: 25
Media Height: 0 Media Width: 48
Media Height: 0 Media Width: 96
Media Height: 0 Media Width: 192
Media Height: 0 Media Width: 383
Media Height: 0 Media Width: 96
Media Height: 0 Media Width: 48
Media Height: 0 Media Width: 25

when the page doesn't specify a size for the <audio> element, it would use only the css code that is set up for the width and height percentages. 

The problem with the code now is that when I take out if(this.isAudioOnly) return; it would not show the audio controls and scrubber. What I wanted to do was to have it set up the width and height for the audio controls respectively and determine whether or not to reduce the size of the dimensions. I was wondering if I can get some feedback on how I can solve this problem.
Flags: needinfo?(jaws)
Attached patch Patch (obsolete) — Splinter Review
Bao or Sean, can you test out this patch? It seems to fix all the issues with the audio control sizing, as well as fixing issues with entering fullscreen and toggling playback for audio elements.
Attachment #757011 - Attachment is obsolete: true
Attachment #758368 - Flags: feedback?(bduong)
Flags: needinfo?(jaws)
Attached patch Patch v1.0 (obsolete) — Splinter Review
Attachment #758409 - Flags: review?(jaws)
Attachment #758409 - Flags: feedback?(jaws)
Attached patch Patch v1.0 (obsolete) — Splinter Review
Attachment #758409 - Attachment is obsolete: true
Attachment #758409 - Flags: review?(jaws)
Attachment #758409 - Flags: feedback?(jaws)
Attachment #758419 - Flags: review?(jaws)
Attachment #758419 - Flags: feedback?(jaws)
Attached patch Patch v1.0 (obsolete) — Splinter Review
Attachment #758419 - Attachment is obsolete: true
Attachment #758419 - Flags: review?(jaws)
Attachment #758419 - Flags: feedback?(jaws)
Attachment #758427 - Flags: review?(jaws)
Attachment #758427 - Flags: feedback?(jaws)
Attached file Patch v1.0 (obsolete) —
Attachment #758429 - Flags: review?(jaws)
Attachment #758429 - Flags: feedback?(jaws)
Attached patch Patch v1.0 (obsolete) — Splinter Review
Attachment #758427 - Attachment is obsolete: true
Attachment #758429 - Attachment is obsolete: true
Attachment #758427 - Flags: review?(jaws)
Attachment #758427 - Flags: feedback?(jaws)
Attachment #758429 - Flags: review?(jaws)
Attachment #758429 - Flags: feedback?(jaws)
Attachment #758430 - Flags: review?(jaws)
Attachment #758430 - Flags: feedback?(jaws)
Comment on attachment 758430 [details] [diff] [review]
Patch v1.0

Review of attachment 758430 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/content/widgets/videocontrols.xml
@@ +1346,5 @@
>                  _playButtonWidth : 0,
>                  _durationLabelWidth : 0,
>                  _muteButtonWidth : 0,
>                  _fullscreenButtonWidth : 0,
> +                _controlBarHeight : 28,

I don't see why setting this to 28 will change anything. The initial value is overwritten in setupInitialState().
Attachment #758430 - Flags: review?(jaws)
Attachment #758430 - Flags: review-
Attachment #758430 - Flags: feedback?(jaws)
Attachment #758368 - Flags: feedback?(bduong)
Attached patch Patch v1.0 (obsolete) — Splinter Review
Attachment #758430 - Attachment is obsolete: true
Attachment #758718 - Flags: review?(jaws)
Attachment #758718 - Flags: feedback?(jaws)
Comment on attachment 758718 [details] [diff] [review]
Patch v1.0

Review of attachment 758718 [details] [diff] [review]:
-----------------------------------------------------------------

What is the difference between this patch and the one that I uploaded?
Attachment #758718 - Flags: review?(jaws)
Attachment #758718 - Flags: feedback?(jaws)
Apparently since you didnt think that _controlBarHeight set to 28 wont make a difference. I changed it back to 0. I tried out your patch and it worked fine once i set the height to 28px on the test file. So I was wondering what else should I change?
Well, we'll only need to change something if it's not working correctly. Unfortunately, we don't have a plan for what to do with media elements that have a height of 0, since we don't want to change the way the page is laid out.

I'll move my original patch forward for review.
Attachment #758718 - Attachment is obsolete: true
Attached patch Patch v1.1 (obsolete) — Splinter Review
This patch combines a few different fixes for our audio controls. I can split them to separate bugs if you'd like, or we can just update the bug summary to reflect the various fixes.
Attachment #758368 - Attachment is obsolete: true
Attachment #759349 - Flags: review?(dolske)
Comment on attachment 759349 [details] [diff] [review]
Patch v1.1

Review of attachment 759349 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/content/widgets/videocontrols.css
@@ +91,5 @@
>  
>  .controlBar[size="hidden"],
>  .controlBar[size="small"] .durationBox,
>  .controlBar[size="small"] .durationLabel,
> +.controlBar[size="small"] .scrubberStack,

Why is this changing from visibility:hidden to visibility:collapse?

::: toolkit/content/widgets/videocontrols.xml
@@ +1035,5 @@
>                  },
>  
>                  toggleFullscreen : function () {
> +                    if (this.isAudioOnly)
> +                        return;

This seems wrong. If it's an audio file, we just shouldn't show the FS button/menu instead of making it do nothing. And we have code to do that -- is it broken?

@@ +1068,5 @@
>  
>                  clickToPlayClickHandler : function(e) {
> +                    // Don't toggle playback for non-left clicks or for
> +                    // audio-only media since there is nothing visual to click on.
> +                    if (e.button != 0 || this.isAudioOnly)

Similar comment -- this handler is only attached to two elements...

- clickToPlay, which should be hidden for audio-only elements
- controlsSpacer, which should be height=0 for <audio>

I think only controlsSpacer would actually be clickable in the first place, for <video src=audio-only.ogg> since video gets a default height. Is there a reason to make clicking not work in this specific case?

::: toolkit/themes/osx/global/media/videocontrols.css
@@ +48,5 @@
>  }
>  
> +.controlBar[size="small"] > .playButton {
> +  margin-right: 0;
> +}

Hmm, was this broken for small-dimension <video>? *tests* oh dear. Did we goof this from the beginning, or did something else make this regress?

It's resetting the negative-margin used for the scrubber overlap, which has basically always been there... :|
Attachment #759349 - Flags: review?(dolske) → review-
(In reply to Justin Dolske [:Dolske] from comment #44)
> Comment on attachment 759349 [details] [diff] [review]
> Patch v1.1
> 
> Review of attachment 759349 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: toolkit/content/widgets/videocontrols.css
> @@ +91,5 @@
> >  
> >  .controlBar[size="hidden"],
> >  .controlBar[size="small"] .durationBox,
> >  .controlBar[size="small"] .durationLabel,
> > +.controlBar[size="small"] .scrubberStack,
> 
> Why is this changing from visibility:hidden to visibility:collapse?

Because <video> or <audio> that were 64px wide still couldn't fit the controls. Video doesn't matter much, who does that anyway lol?, but for <audio> I can picture people wanting a small 64px wide x 35px high element.

> ::: toolkit/content/widgets/videocontrols.xml
> @@ +1035,5 @@
> >                  },
> >  
> >                  toggleFullscreen : function () {
> > +                    if (this.isAudioOnly)
> > +                        return;
> 
> This seems wrong. If it's an audio file, we just shouldn't show the FS
> button/menu instead of making it do nothing. And we have code to do that --
> is it broken?

We now have dblclick on the controlsSpacer to enter fullscreen.

> @@ +1068,5 @@
> >  
> >                  clickToPlayClickHandler : function(e) {
> > +                    // Don't toggle playback for non-left clicks or for
> > +                    // audio-only media since there is nothing visual to click on.
> > +                    if (e.button != 0 || this.isAudioOnly)
> 
> Similar comment -- this handler is only attached to two elements...
> 
> - clickToPlay, which should be hidden for audio-only elements
> - controlsSpacer, which should be height=0 for <audio>
> 
> I think only controlsSpacer would actually be clickable in the first place,
> for <video src=audio-only.ogg> since video gets a default height. Is there a
> reason to make clicking not work in this specific case?

An audio element with a specified height that is greater than 28px will have a non-zero height controlsSpacer. That blank area shouldn't react to clicks since it's not obvious you are clicking on something.

> ::: toolkit/themes/osx/global/media/videocontrols.css
> @@ +48,5 @@
> >  }
> >  
> > +.controlBar[size="small"] > .playButton {
> > +  margin-right: 0;
> > +}
> 
> Hmm, was this broken for small-dimension <video>? *tests* oh dear. Did we
> goof this from the beginning, or did something else make this regress?
> 
> It's resetting the negative-margin used for the scrubber overlap, which has
> basically always been there... :|

We didn't goof this from the beginning. The change above from visibility:hidden to visibility:collapse makes this change necessary, but it now means that we can have the play/pause and mute buttons right next to each other.
Comment on attachment 759349 [details] [diff] [review]
Patch v1.1

Re-requesting review. Please see my response in comment #45.
Attachment #759349 - Flags: review- → review?(dolske)
Review ping?
Attached image Screenshot of Patch v.1.1 (obsolete) —
Something's still not right here. (Window on top is with patch, background is Nightly, video is 70 pixels wide)
Comment on attachment 759349 [details] [diff] [review]
Patch v1.1

I think I'm ok with previous explanations. But the visual appearance is still goofy, so let's just get it sane.

Better testcase: http://dolske.net/mozilla/tests/video/sizes.html
Attachment #759349 - Flags: review?(dolske) → review-
Updated:

http://dolske.net/mozilla/tests/video/sizes_audio.html
http://dolske.net/mozilla/tests/video/sizes_video.html

Also just noticed http://panuhorsmalahti.fi/audiodimensions.html was already listed here, that's useful too.

I'm now getting empty/tiny audio elements though. O_o
Mentor: jaws
Whiteboard: [mentor=jaws][lang=js] → [lang=js]
Assignee: bduong → nobody
Status: ASSIGNED → NEW
Hello everyone! I am new to Bugzilla and this would be my first  mentored bug. I have little knowledge of python, HTML and CSS. In case, no one is working on this bug, may I please pick this up?
It would also  be great if someone please explains me the working procedure in case this bug is assigned to me.
Thanks in advance!
Thanks for your interest Preeti! Looking at the links in comment 50, this bug appears to have been fixed in the past five years.

I did some searching and it appears that it was fixed by these two bugs:

The first part is https://bugzilla.mozilla.org/show_bug.cgi?id=1271765 and the second part is a patch within this range, https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=9af23c413a1f8d337b19b4f8450e241e91b71136&tochange=587daa4bdc4b40b7053f4ca3b74723ca747f3b52

Bug 1271765 mainly fixed this, though without the second part audio elements that were very narrow weren't getting rendered.
Status: NEW → RESOLVED
Closed: 6 years ago
Depends on: 1271765
Resolution: --- → FIXED
Attachment #759349 - Attachment is obsolete: true
Attachment #770500 - Attachment is obsolete: true
(In reply to Jared Wein [:jaws] (please needinfo? me) from comment #52)
> Thanks for your interest Preeti! Looking at the links in comment 50, this
> bug appears to have been fixed in the past five years.
> 
> I did some searching and it appears that it was fixed by these two bugs:
> 
> The first part is https://bugzilla.mozilla.org/show_bug.cgi?id=1271765 and
> the second part is a patch within this range,
> https://hg.mozilla.org/mozilla-central/
> pushloghtml?fromchange=9af23c413a1f8d337b19b4f8450e241e91b71136&tochange=587d
> aa4bdc4b40b7053f4ca3b74723ca747f3b52
> 
> Bug 1271765 mainly fixed this, though without the second part audio elements
> that were very narrow weren't getting rendered.

Ok, Thank you!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: