Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP: Implement HTMLMediaElement.loop attribute #22321
Conversation
highfive
commented
Nov 30, 2018
|
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. |
highfive
commented
Nov 30, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Nov 30, 2018
|
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> | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Nov 30, 2018
Member
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>, | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Nov 30, 2018
Member
loop is a reserved keyword in Rust, so I would be very surprised if this passed compilation.
This comment has been minimized.
This comment has been minimized.
ferjm
Nov 30, 2018
Member
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() { | |||
This comment has been minimized.
This comment has been minimized.
KiChjang
Nov 30, 2018
Member
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?
This comment has been minimized.
This comment has been minimized.
ferjm
Nov 30, 2018
Member
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 #22297 in the comment.
- Set
playback_positiontodefault_playback_start_positionhere.
|
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 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>, | |||
This comment has been minimized.
This comment has been minimized.
ferjm
Nov 30, 2018
Member
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() { | |||
This comment has been minimized.
This comment has been minimized.
ferjm
Nov 30, 2018
Member
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 #22297 in the comment.
- Set
playback_positiontodefault_playback_start_positionhere.
|
Thanks for the comments. Working on it :D |
aa0cbad
to
0f09af3
|
Working hard to compile it locally... |
0f09af3
to
1ca5944
|
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? |
…ement-loop
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 -->
|
|
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 -->
|
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! |
kkpoon commentedNov 30, 2018
•
edited
Implement HTMLMediaElement.loop attribute
loopattribute inHTMLMediaElementloopvalue asCell::new(false)playback_positiontodefault_playback_start_positioninPlayerEvent::EndOfStreamevent whenloopis set./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is