-
Notifications
You must be signed in to change notification settings - Fork 2k
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
MediaSession enabled all builds from FF82 #6845
Conversation
@hamishwillee I've marked this as info-needed and not-ready, pending an answer on this bit. Or we can move on to reviewing without it, if you want to open an issue to track that question separately. Thank you! |
@ddbeck On a closely related matter, would appreciate your advice. Navigator.mediaSession is how the spec says you get hold of a MediaSession. So to my mind there really is no way the compatibility for these two objects should not match. You wouldn't invent a non-spec way to access everything else 'according to spec'. I think that probably So I propose to also make these match. Reasonable? |
@ddbeck I asked the engineer about this change on FF. He says that a bunch of pages can use the media control API and it is up to the user agent (device) to select which one gets used in the lock screen (etc). However right now Fenix is still using their own android component and so none of the sessions will be selected. Doesn't quite feel "right", but based on his advice I plan to add it as version-supported in FF82 on Android. I thought perhaps a note like below - reasonable?
|
@hamishwillee this looks OK to me; I'd move forward with that change. |
@hamishwillee in the list of files updated, I don't see |
@hamishwillee I also noticed that this PR does not include data for the |
@chrisdavidmills That was my question in #6845 (comment) - I think it was missed last time MediaSession got updated. I've made MediaSession and Navigator.mediaSession match as much as sensibly possible. |
492d00d
to
d50b2dc
Compare
@chrisdavidmills @ddbeck I added
@ddbeck This should be ready to review |
@ddbeck This is just a reminder. I am not nagging. Honest :-) |
@hamishwillee Thanks for the nudge. I was more or less out last week, so it might take me a little time to catch up on things. I started on reviewing this before, but the backstory (e.g., #6002) is so complicated and angsty that it's slowing going. Thanks for your patience! |
Still not nagging :-). |
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 your reminders, @hamishwillee. The actual version data looks unobjectionable. 👍 There are a couple of structural hurdles here, however (not your fault—just a complexity we have to face here). I've got a couple big line comments to get started on those. Thanks again!
api/MediaMetadata.json
Outdated
"firefox_android": { | ||
"version_added": null | ||
"version_added": "82", | ||
"notes": "The particular Media Session used for Android media control depends on the user agent. The Android browser implementation does not allow any session to be selected as active." |
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'm having a hard time understanding this note. I ended up with a bunch of questions.
What does "depends on the user agent" mean here? Isn't Firefox the user agent? What about "does not allow any session to be selected as active"? This feature is the MediaMetadata
interface itself. How does one use the interface to "select" something?
I need some help here to figure out how to translate this into something that a web developer can act on. MediaMetadata
apparently has some limitation on Android. As developer, what can I do with it? What can't I do with it? How is it like other implementations? How is it different?
I see now that this note appears in several places. When is it most important to developers? When are they most likely to notice the behavior on Android?
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.
@ddbeck What this says is that the API has been implemented but really can't be used. However it code running in a page that uses this API will never know that. Explanation:
The theory is that pages use this API to be able to expose media data and control to a user agent. In theory a user should be able to access an interface to select from pages using the API (and other media sources) and set one as being used by standard mechanisms for media display/control on the device. In other words, if your device supports playing media from the lockscreen (and displaying the current song say) then you should be able to select one of the pages as the source for media.
But what has happened is that the API was implemented, but the components required to make that UI selection to assign a page to the lockscreen (say) do not work/exist. So the API "works" - you can write a page that uses it. But then you still can't select the page.
An subtle point here though is that many pages might use the API, and most of them will not be selected by the user agent. No page actually knows if it is being used. There is nothing a developer can do about this.
The text is what the developer thought made sense to cover this. It is strictly accurate. But perhaps we should be blunt and say - there is no point using this?
Maybe something more like (?):
At time of writing the Android browser implementation does not allow web pages to be set as a media source.
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.
Ah, OK. Thank you, @hamishwillee! That's really helpful. I think this helps me understand what's going on here a bit better. I think we need to revise the note and tweak the data a bit.
I think your draft note is pretty good start. To help this note standalone better in multiple contexts (MDN's not the only BCD consumer), does something like this revision work?
Firefox does not implement a user interface for choosing a web page as a media source. This API is exposed, but has no corresponding user-facing behavior.
That seems like a big enough caveat that we'd also want to set "partial_implementation": true
.
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.
Firefox does not implement a user interface for choosing a web page as a media source. This API is exposed, but has no corresponding user-facing behavior.
I will go back and check with engineering because it may be that the missing part of the picture is outside of the browser/in the OS; in which case this feels wrong. That then would also make "partial_implementation": true
feel wrong.
However FMI, if we did do this, would the note exist on every API? I. not clear to me whether the note would only perhaps go on the main Session and Action.
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.
@ddbeck An excellent description of the integration added here. In summary, it is as we thought - this API is integrated into GeckoView, but anything that uses GeckoView must further integrate with the underlying platform via the embedding application - in this case Firefox Android.
I have therefore taken your advice and changed to partial implementation and added note as below in all locations.
Firefox does not yet integrate this API into Android's media control interfaces. Hence the API is exposed, but the corresponding user-facing behavior is not available.
Should be good to review again.
api/MediaPositionState.json
Outdated
@@ -0,0 +1,248 @@ | |||
{ | |||
"api": { | |||
"MediaPositionState": { |
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.
OK, this steps into a complex question about whether and how to represent IDL dictionaries in BCD. In this case, since, as far as I can tell, MediaPositionState
only matters for one method, we should move the subfeatures of MediaPositionState
to api.MediaSession.setPositionState
(e.g., described as "<code>state.duration</code> argument"
) and get rid of this file.
Now, why we should do this pretty complex. I'm sorry about this. If you're really curious, you can read #6002 and #6265, but it's a long story. Here's my highly-opinionated summary:
The Media Session spec names several abstract dictionaries as a convenience to spec authors and browser developers. However, these dictionary names don't have a concrete manifestation for web developers; they indirectly appear as patterns for concrete return values and method arguments. Consequently, it's an open question what it means to "support" an abstract dictionary.
That said, we don't have a good answer in BCD or on MDN for how to represent these things yet. There's way more discussion on this point in #7287. In the past (e.g., #6265), I've compromised when such dictionaries have touched many APIs, but I've resisted introducing them in cases like this one.
As far as I can tell, MediaPositionState
represents one thing only: the structure of the object argument to MediaSession.setPositionState()
. I don't know what it means to support MediaPositionState
, but I do have a sense for what it means for setPositionState()
to support state.duration
. We can represent this information as subfeatures of the method and call it a day.
6cf6487
to
210f949
Compare
@@ -270,7 +274,8 @@ | |||
} | |||
], | |||
"firefox_android": { | |||
"version_added": false | |||
"version_added": "82", |
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.
@ddbeck With respect to your comment on MediaPositionState
here: #6845 (comment)
I have deleted the specific doc for the MediaPositionState
. There is no code change here, so arguably we could just ignore adding anything for this - I added it because I though it was an omission. If we do need subfeature documentation, could you point me at a good example of how this would be done in BCD that I can copy.
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.
A quick search turned up something like api.HTMLOrForeignElement.focus.preventScroll_option
(MDN). The equivalent here would be something like api.MediaSession.setPositionState.{duration,playbackRate,position}
, or, to preserve the top-level MediaPositionState
, api.MediaSession.setPositionState.MediaPositionState.{duration,playbackRate,position}
.
Also an unrelated heads up: you don't need to rebase PRs on BCD. We squash most merges anyway.
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 @ddbeck . I think I've done this bit "as expected" now. Note again that I've copied in the same note as we discussed above - and I'm not sure this is appropriate within this level of nesting.
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.
OK, I think we're getting pretty close here. Some hopefully straight-forward changes to make to get this in. Thank you, @hamishwillee for helping to fix up this (sometimes agitating) set of features.
api/MediaSession.json
Outdated
}, | ||
"MediaPositionState": { | ||
"__compat": { | ||
"description": "Dictionary passed to <code>setPositionState</code> to specify play position within a track (<code>{duration, playbackRate, position}</code>).", |
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.
Yeah, I see what you mean here. IIRC, you had subfeatures for duration, playbackRate, position in your original PR (that data seems to have disappeared with a rebase, so I don't know this for a fact). Seeing this singular MediaPositionState
feature though, without anything underneath, I don't think it adds anything to the parent feature—it's effectively saying, "this method has an argument, which is an object".
My inclination here is to drop this feature and move on.
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.
Completely agree. Done!
Add FF for Android notes to match FF notes
6d1bc92
to
d947b7d
Compare
@ddbeck Thanks very much. Deleted the dictionary and accepted your note (yes, much better). |
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.
Finally! This was a hard one, but you stuck with it. Thank you, @hamishwillee! 🎉
Thanks for your patience. Possibly the most important skill for a tech writer - even more than "writing good" :-) |
MediaSession (and friends) are enabled on all builds from FF82 - this adds the version. See bug Enable MediaSession API
dom.media.mediasession.enabled
so set covered is everything that was previously tagged with that preference.