-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
WIP: Implement HTMLMediaElement.loop attribute #22321
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @avadacatavra (or someone else) soon. |
Heads up! This PR modifies the following files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I have some minor nits and a general question regarding the playback ended handler.
@@ -163,6 +163,8 @@ pub struct HTMLMediaElement { | |||
paused: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay> | |||
autoplaying: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the doc comments above, you'll need to remove media.html
from the URL.
@@ -163,6 +163,8 @@ pub struct HTMLMediaElement { | |||
paused: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay> | |||
autoplaying: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop> | |||
loop: Cell<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop
is a reserved keyword in Rust, so I would be very surprised if this passed compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we don't need to add the attribute here in this case. We can use the make_bool_getter!
and make_bool_setter!
macros instead and use self.Loop()
to check the attribute's value. You can take the autoplay attribute as an example.
@@ -1218,6 +1221,12 @@ impl HTMLMediaElement { | |||
if self.ready_state.get() < ReadyState::HaveMetadata { | |||
self.queue_dedicated_media_source_failure_steps(); | |||
} | |||
if self.loop.get() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The step annotations above indicate that this may be the incorrect location to add the looping functionality. I suspect the concept of the end of the media resource may not even be implemented yet. @ferjm Am I correct in claiming so? If not, where do we handle the playback ended event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept of the end of the media resource is not implemented yet. It should be done as part of #22294.
I do believe this is the right place to add the looping functionality. But apart from seeking to the start position we need to do a couple of things more:
- Do an early return if the previous condition is
true
, as we don't want to loop if there are errors. - Add a XXX comment saying that we need to identify if the stream is seekable or not to decide if we can loop. Please, reference Implement HTMLMediaElement.seekable attribute #22297 in the comment.
- Set
playback_position
todefault_playback_start_position
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! This is a good start, but we need to make some changes. I left some comments in the code.
We need to add the loop
attribute to the HTMLMediaElement WebIDL file. It's already there, but commented out.
We have a Web Platform Test at tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html to test this functionality. You will likely need to update the tests expectations.
Finally, please, test that the code builds and works as expected locally. Note that the looping step may take some time as we don't have a media cache yet, so we discard everything that we play and seeking to the start will require fetching the data again from the network.
@@ -163,6 +163,8 @@ pub struct HTMLMediaElement { | |||
paused: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/#attr-media-autoplay> | |||
autoplaying: Cell<bool>, | |||
/// <https://html.spec.whatwg.org/multipage/media.html#attr-media-loop> | |||
loop: Cell<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we don't need to add the attribute here in this case. We can use the make_bool_getter!
and make_bool_setter!
macros instead and use self.Loop()
to check the attribute's value. You can take the autoplay attribute as an example.
@@ -1218,6 +1221,12 @@ impl HTMLMediaElement { | |||
if self.ready_state.get() < ReadyState::HaveMetadata { | |||
self.queue_dedicated_media_source_failure_steps(); | |||
} | |||
if self.loop.get() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept of the end of the media resource is not implemented yet. It should be done as part of #22294.
I do believe this is the right place to add the looping functionality. But apart from seeking to the start position we need to do a couple of things more:
- Do an early return if the previous condition is
true
, as we don't want to loop if there are errors. - Add a XXX comment saying that we need to identify if the stream is seekable or not to decide if we can loop. Please, reference Implement HTMLMediaElement.seekable attribute #22297 in the comment.
- Set
playback_position
todefault_playback_start_position
here.
Thanks for the comments. Working on it :D |
aa0cbad
to
0f09af3
Compare
Working hard to compile it locally... |
0f09af3
to
1ca5944
Compare
Hi @ferjm, |
Yes, that's expected. That test is checking the interfaces exposed to web content. We weren't exposing the Did you check if https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html is passing? |
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 - [ ] These changes fix #22294. <!-- 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/22348) <!-- Reviewable:end -->
Hi @ferjm I check the servo.log from test-wtp,
It seems being skipped. Any idea about this?, I run it on a machine in DigitalOcean. ubuntu-1804 8ram4vcpu. Thanks |
https://github.com/servo/servo/blob/master/tests/wpt/metadata/html/semantics/embedded-content/media-elements/audio_loop_base.html.ini#L3 shows that this test has been disabled. Try removing that line! |
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
@bors-servo try=wpt |
WIP: Implement HTMLMediaElement.loop attribute Implement HTMLMediaElement.loop attribute - enabled `loop` attribute in `HTMLMediaElement` - initialised `loop` value as `Cell::new(false)` - set `playback_position` to `default_playback_start_position` in `PlayerEvent::EndOfStream` event when `loop` is set --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #22290 (github issue number if applicable). --- - [ ] There are tests for these changes OR <!-- 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/22321) <!-- Reviewable:end -->
I get the test fail about reached the unreachable code. I think it is the media error event at here https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/media-elements/audio_loop_base.html#L35 Any way to check about the detail of that error? |
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
@bors-servo try=wpt |
WIP: Implement HTMLMediaElement.loop attribute Implement HTMLMediaElement.loop attribute - enabled `loop` attribute in `HTMLMediaElement` - initialised `loop` value as `Cell::new(false)` - set `playback_position` to `default_playback_start_position` in `PlayerEvent::EndOfStream` event when `loop` is set --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #22290 (github issue number if applicable). --- - [ ] There are tests for these changes OR <!-- 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/22321) <!-- Reviewable:end -->
💔 Test failed - linux-rel-css |
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
☔ The latest upstream changes (presumably #22522) made this pull request unmergeable. Please resolve the merge conflicts. |
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
Implement Ended media attribute <!-- Please describe your changes on the following line: --> This PR should implement: * New method `HTMLMediaElement::earliest_possible_position()` for the [earliest possible position](https://html.spec.whatwg.org/multipage/media.html#earliest-possible-position) * `Ended` attribute following https://html.spec.whatwg.org/multipage/media.html#ended-playback * Queue steps for when the playback position reaches the end This PR contains placeholders for the following issues (I can rebase changes after the corresponding PRs get merged) - #22321 (Define the Loop attribute) - #22293 (To identify playback direction. Either forwards or backwards) --- <!-- 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 #22294. <!-- 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/22348) <!-- Reviewable:end -->
Oh, I just though it is done. |
@kkpoon how are things going? Are you still interested in working on this issue? |
@ferjm Sorry that I am not able to work on this at this moment. You may take over this PR or close it for other to work on this. Haven't update the status and I am sorry about that. |
No worries! Let's close this for now. Feel free to reopen if you find the time to work on it again. Thanks! |
Implement HTMLMediaElement.loop attribute
loop
attribute inHTMLMediaElement
loop
value asCell::new(false)
playback_position
todefault_playback_start_position
inPlayerEvent::EndOfStream
event whenloop
is set./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is