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 mediasession set positon state #24885

Merged

Conversation

@shnmorimoto
Copy link
Contributor

shnmorimoto commented Nov 27, 2019

fix #24808

Bonus points if you want to tweak the existing UI by adding a progress bar, and the info about the current position and total duration.

I haven't implemented this yet.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #24808 (GitHub issue number if applicable)
  • There are tests for these changes OR
@highfive
Copy link

highfive commented Nov 27, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmlmediaelement.rs, components/script/dom/mediasession.rs, components/script/dom/webidls/MediaSession.webidl
  • @KiChjang: components/script/dom/htmlmediaelement.rs, components/script/dom/mediasession.rs, components/script/dom/webidls/MediaSession.webidl
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 27, 2019

#24808 (comment)

Extend the existing HostTrait trait with a new on_media_session_set_position_state or such method. And implement that method for the C and JNI APIs

For the Android part, extend the existing Callbacks and Client interfaces with the new onMediaSessionSetPositionState callback. And implement it here and here.

To be honest, I don't have enough understanding of these behaviors.
Is there any way to test that these are implemented correctly?

@jdm
Copy link
Member

jdm commented Nov 27, 2019

r? @ferjm

@highfive highfive assigned ferjm and unassigned asajeffrey Nov 27, 2019
Copy link
Member

ferjm left a comment

This is a great start, but we need to make some changes.

In addition to the comments I added, we should send MediaSessionEvent::SetPositionState events when the media player notifies about position updates.

components/embedder_traits/lib.rs Show resolved Hide resolved
ports/libsimpleservo/api/src/lib.rs Outdated Show resolved Hide resolved
ports/libsimpleservo/capi/src/lib.rs Show resolved Hide resolved
components/script/dom/mediasession.rs Show resolved Hide resolved
components/script/dom/mediasession.rs Outdated Show resolved Hide resolved
ports/libsimpleservo/api/src/lib.rs Outdated Show resolved Hide resolved
ports/libsimpleservo/jniapi/src/lib.rs Outdated Show resolved Hide resolved
ports/libsimpleservo/jniapi/src/lib.rs Outdated Show resolved Hide resolved
components/script/dom/htmlmediaelement.rs Outdated Show resolved Hide resolved
components/script/dom/htmlmediaelement.rs Outdated Show resolved Hide resolved
@ferjm
Copy link
Member

ferjm commented Nov 28, 2019

To be honest, I don't have enough understanding of these behaviors.
Is there any way to test that these are implemented correctly?

You can test on Android. The instructions to build for this platform are on the README and the wiki.

You can try modifying this example.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:implement_mediasession_set_positon_state branch from 769df62 to 187c90d Nov 29, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 29, 2019

@ferjm Thank you for a great review.

In addition to the comments I added, we should send MediaSessionEvent::SetPositionState events when the media player notifies about position updates.

I added the code for MediaSessionEvent::SetPositionState.

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 29, 2019

You can test on Android. The instructions to build for this platform are on the README and the wiki.

Thanks! I don't have Android right now, so I'll get it and try it.

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 29, 2019

When I change the code under the ports(ex. ports/libsimpleservo/jniapi/src/lib.rs ), it seems that it is not build even if I run ./mach build --dev .

Is this my misunderstanding?

@jdm
Copy link
Member

jdm commented Nov 29, 2019

The build command only builds one of the ports at a time. For libsimpleservo/jniapi, you need to pass the --android argument to ./mach build (https://github.com/servo/servo/wiki/Building-for-Android).

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:implement_mediasession_set_positon_state branch from 187c90d to 17286de Dec 2, 2019
@ferjm
ferjm approved these changes Dec 2, 2019
Copy link
Member

ferjm left a comment

Looks good. Thank you!

r=me with the last minor comments addressed.

// If the duration is not present or its value is null, throw a TypeError.
if state.duration.is_none() {
return Err(Error::Type(
"duration is not preset or its value is null".to_owned(),

This comment has been minimized.

Copy link
@ferjm

ferjm Dec 2, 2019

Member

typo: present

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Dec 2, 2019

Author Contributor

Oops. This is also typo..., Sorry.
done.

}
}

// If the position is not present or its value is null, set it to zero.

This comment has been minimized.

Copy link
@ferjm

ferjm Dec 2, 2019

Member

Remove this comment, please.

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Dec 2, 2019

Author Contributor

Thanks! done.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:implement_mediasession_set_positon_state branch from 17286de to 29d6a35 Dec 2, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 3, 2019

In my local, build is success.
Should I rebase and put commits in one?

@jdm
Copy link
Member

jdm commented Dec 3, 2019

./mach build --libsimpleservo fails with this error:

error[E0609]: no field `on_media_session_set_position_state` on type `CHostCallbacks`
   --> ports\libsimpleservo\capi\src\lib.rs:741:17
    |
741 |         (self.0.on_media_session_set_position_state)(duration, position, playback_rate);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `flush`, `make_current`, `on_alert`, `on_load_started`, `on_load_ended` ... and 11 others
error: aborting due to previous error
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 3, 2019

@jdm Thanks! I'll check.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:implement_mediasession_set_positon_state branch from 29d6a35 to 70b76ca Dec 3, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 3, 2019

I fixed an error when run ./mach build --libsimpleservo.

> ./mach build --libsimpleservo                                                                                                                        implement_mediasession_set_positon_state
   Compiling simpleservo_capi v0.0.1 (/Users/shn/Work/servo/ports/libsimpleservo/capi)
   Completed simpleservo_capi v0.0.1 custom-build (run) in 1.2s
   Completed simpleservo_capi v0.0.1 in 195.3s
    Finished dev [unoptimized + debuginfo] target(s) in 3m 21s
Build Completed in 0:03:22
@shnmorimoto shnmorimoto force-pushed the shnmorimoto:implement_mediasession_set_positon_state branch from 70b76ca to 41ff93e Dec 3, 2019
@jdm
Copy link
Member

jdm commented Dec 3, 2019

@bors-servo r=ferjm

@bors-servo
Copy link
Contributor

bors-servo commented Dec 3, 2019

📌 Commit 41ff93e has been approved by ferjm

@bors-servo
Copy link
Contributor

bors-servo commented Dec 3, 2019

Testing commit 41ff93e with merge 4ba6bfa...

bors-servo added a commit that referenced this pull request Dec 3, 2019
…_state, r=ferjm

Implement mediasession set positon state

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

fix #24808

> Bonus points if you want to tweak the existing UI by adding a progress bar, and the info about the current position and total duration.

I haven't implemented this yet.

---
<!-- 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 #24808 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 3, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 3, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Dec 3, 2019

Testing commit 41ff93e with merge f31a88d...

bors-servo added a commit that referenced this pull request Dec 3, 2019
…_state, r=ferjm

Implement mediasession set positon state

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

fix #24808

> Bonus points if you want to tweak the existing UI by adding a progress bar, and the info about the current position and total duration.

I haven't implemented this yet.

---
<!-- 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 #24808 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 3, 2019

☀️ Test successful - status-taskcluster
Approved by: ferjm
Pushing f31a88d to master...

@bors-servo bors-servo merged commit 41ff93e into servo:master Dec 3, 2019
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Dec 3, 2019
3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

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