Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Audio constructor #21929

Closed
jdm opened this issue Oct 12, 2018 · 5 comments
Closed

Implement Audio constructor #21929

jdm opened this issue Oct 12, 2018 · 5 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Oct 12, 2018

Spec:
https://html.spec.whatwg.org/multipage/media.html#the-audio-element (see NamedConstructor usage in WebIDL)
https://html.spec.whatwg.org/multipage/media.html#dom-audio

Code: components/script/dom/webidls/HTMLAudioElement.webidl, components/script/dom/htmlaudioelement.rs

Tests:

Now that we support actual audio output, we should implement the missing constructor that is used by many websites to create an HTMLAudioElement.

@highfive
Copy link

@highfive highfive commented Oct 12, 2018

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@HrushikeshBodas
Copy link

@HrushikeshBodas HrushikeshBodas commented Oct 12, 2018

@highfive : assign me
@jdm how can I get started? I have forked and cloned the repo

@highfive
Copy link

@highfive highfive commented Oct 12, 2018

Hey @HrushikeshBodas! Thanks for your interest in working on this issue. It's now assigned to you!

@highfive highfive added the C-assigned label Oct 12, 2018
@jdm
Copy link
Member Author

@jdm jdm commented Oct 12, 2018

@HrushikeshBodas There's a similar named constructor for HTMLImageElement, so you can use that as a guide -

[HTMLConstructor, NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
is the webidl, and
pub fn Image(
window: &Window,
width: Option<u32>,
height: Option<u32>,
) -> Fallible<DomRoot<HTMLImageElement>> {
let document = window.Document();
let image = HTMLImageElement::new(local_name!("img"), None, &document);
if let Some(w) = width {
image.SetWidth(w);
}
if let Some(h) = height {
image.SetHeight(h);
}
Ok(image)
is the implementation that matches it. https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image is the specification that describes what the implementation is supposed to do.

@jdm
Copy link
Member Author

@jdm jdm commented Nov 19, 2018

There was a question on IRC about calling setting the media element's src from this new constructor. You will need to import the HTMLMediaElementMethods trait in order to call the SetSrc method like so: audio_element.upcast::<HTMLMediaElement>().SetSrc(...).

@vn-ki vn-ki mentioned this issue Nov 19, 2018
4 of 5 tasks complete
bors-servo added a commit that referenced this issue Nov 20, 2018
Implement Audio constructor

<!-- Please describe your changes on the following line: -->
Implement Audio constructor

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21929 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because *tests were already there and the expectations were updated*.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22227)
<!-- Reviewable:end -->
@ferjm ferjm added this to Done in Media playback Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.