-
Notifications
You must be signed in to change notification settings - Fork 29
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
Update index.bs with ChapterInformation #308
Conversation
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.
There's a section of examples near the bottom of the spec. I think we should also add an example of adding chapter information
index.bs
Outdated
|
||
The <dfn dict-member for="ChapterInformation">startTime</dfn> <a>dictionary member</a> | ||
is used to specify the {{ChapterInformation}} object's {{MediaImage/startTime}} in | ||
seconds. It should always be positive. |
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.
Can it also be zero? I'd guess most first chapters would have a startTime of zero
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.
Changed it to "should not be negative."
Updated the example section. Also updated the explainer.md in this pr. |
ChapterInformation will be added to the MediaMetadata Github pr: w3c/mediasession#308 This cl implements it on the blink layer. Bug: b/316045178 Change-Id: Ic06140e1aed1094d3db68fd167c9acf14c3cd2fa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5124302 Commit-Queue: Alex Newcomer <[email protected]> Reviewed-by: Xianzhu Wang <[email protected]> Reviewed-by: Mohamed Heikal <[email protected]> Reviewed-by: Joe Mason <[email protected]> Cr-Commit-Position: refs/heads/main@{#1240183}
index.bs
Outdated
}; | ||
|
||
dictionary MediaMetadataInit { | ||
DOMString title = ""; | ||
DOMString artist = ""; | ||
DOMString album = ""; | ||
sequence<MediaImage> artwork = []; | ||
sequence<ChapterInformation> chapterInfo = []; |
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.
If we introduce a ChapterInformationInit, this could be a ChapterInformationInit instead (which would allow passing either ChapterInformationInit or ChapterInformation 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.
Done. Shall I also use ChapterInformationInit
in the MediaMetadata interface declaration(L951)?
index.bs
Outdated
better to do this with IDL primitives instead of JS - see | ||
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004 --> | ||
<li> | ||
Call <a lt="freeze">Object.freeze</a> on <var>image</var>, to prevent |
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.
This seems not great... yeah, maybe this should be an interface.
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.
Have changed ChapterInformation
to an interface in this pr. For MediaImage
, it might be better to submit a separate pr under the corresponding issue.
index.bs
Outdated
getting, it MUST return the result of the following steps: | ||
<ol> | ||
<li> | ||
Let <var>frozenArtwork</var> be an empty list of type {{MediaImage}}. |
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.
Still kinda not great that we have ImageResource and MediaImage...
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.
Are they referring to the same thing? I see we are using MediaImage
in MediaMetadata
, so I also use it in the ChapterInformation
.
Co-authored-by: youennf <[email protected]>
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.
- @jan-ivar, @ChunMinChang , since you have thoughts in The freezing in the artwork getter is broken #237.
}; | ||
|
||
dictionary MediaMetadataInit { | ||
DOMString title = ""; | ||
DOMString artist = ""; | ||
DOMString album = ""; | ||
sequence<MediaImage> artwork = []; | ||
sequence<ChapterInformationInit> chapterInfo = []; |
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 do not see ChapterInformationInit being defined 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.
It is defined at L1184, can I use it 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.
This whole section is somehow redundant with web idl.
Since we use ChapterInformationInit, it seems to make sense to add it there as well, since it seems this would be the only one missing 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.
Let's add ChapterInformationInit for consistency here
index.bs
Outdated
|
||
The <dfn dict-member for="ChapterInformation">startTime</dfn> <a>dictionary member</a> | ||
is used to specify the {{ChapterInformation}} object's {{MediaImage/startTime}} in | ||
seconds. It should not be negative. |
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.
Avoid "should" and describe what MUST happen if it is negative.
This should be done in a ChapterInformation(init)
constructor (similar to MediaMetadata(init)), which should throw TypeError on invalid input, as well as run the convert artwork algorithm.
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.
Done.
index.bs
Outdated
The <dfn dict-member for="ChapterInformation">title</dfn> <a>dictionary member</a> is | ||
used to specify the {{ChapterInformation}} object's {{MediaImage/title}}. | ||
|
||
The <dfn dict-member for="ChapterInformation">startTime</dfn> <a>dictionary member</a> | ||
is used to specify the {{ChapterInformation}} object's {{MediaImage/startTime}} in | ||
seconds. It should not be negative. | ||
|
||
The <dfn dict-member for="ChapterInformation">artwork</dfn> <a>dictionary member</a> | ||
is used to specify the {{ChapterInformation}} object's {{MediaImage/artwork}}. On | ||
getting, it MUST return the result of the following steps: |
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.
Dictionary members cannot have getters or setters.
This section appears to conflate the dictionary members with the interface attributes, which is confusing. We should describe them separately like we do for MediaMetadata.
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 have changed it to an interface now as another comment suggested. I also followed the MediaMetadata 's description and rewrote this part in the latest commit :]
index.bs
Outdated
Let <var>frozenArtwork</var> be an empty list of type {{MediaImage}}. | ||
</li> | ||
<li> | ||
For each <var>entry</var> in the {{ChapterInformation}}'s <a | ||
for="ChapterInformation">artwork images</a>, perform the following steps: | ||
<ol> | ||
<li> | ||
Let <var>image</var> be a new {{MediaImage}}. |
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.
Creating new objects in a getter is an anti-pattern, especially in a frozen array. It violates § 6.1. Attributes should behave like data properties. See also crbug 94665.
I understand this is copied from https://w3c.github.io/mediasession/#dom-mediametadata-artwork but that is also wrong and redundant since the MediaMetadata(init) already runs "the convert artwork algorithm with init’s artwork as input and set metadata’s artwork images as the result if it succeeded."
IOW we ran convert (instantiated objects) on set, so no need to run it again (instantiating more objects) on every get. The attribute getter can simply return artwork images.
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.
Updated to:
"The artwork attribute reflects the ChapterInformation's artwork images. On getting, it MUST return the ChapterInformation's artwork. On setting, it MUST run the convert artwork algorithm with the new value as input, and set the ChapterInformation's artwork images as the result if it succeeded."
Let me know what you think.
index.bs
Outdated
On setting, it MUST run the <a>convert artwork algorithm</a> with the new value as | ||
<var>input</var>, and set the {{ChapterInformation}}'s <a for="ChapterInformation">artwork | ||
images</a> as the result if it succeeded. |
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.
This needs to be in the constructor algorithm
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.
Updated.
Co-authored-by: Jan-Ivar Bruaroey <[email protected]>
Co-authored-by: Jan-Ivar Bruaroey <[email protected]>
Hey @jan-ivar, thanks for the review. Can you PTAL again at the latest patchset? |
Co-authored-by: François Daoust <[email protected]>
Co-authored-by: François Daoust <[email protected]>
constructor, when invoked, MUST run the following steps: | ||
|
||
<ol> | ||
<li> |
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.
... and NaN (similar to the steps for setPositionState
)
Co-authored-by: Chris Needham <[email protected]>
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 added one minor comment, but apart from that, it all looks good to me. Thank you!
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.
LGTM with some nits and the fix from @tidoust! Thanks!
index.bs
Outdated
Run the <a>convert artwork algorithm</a> with <var>init</var>'s | ||
{{ChapterInformationInit/artwork}} as <var>input</var> and set |
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.
This looks good but requires fixing the convert artwork algorithm algorithm to expect artwork
instead of input
(right now it still says "For each entry in input’s artwork, perform the following steps:") (plus fixing the other call to that algorithm).
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.
Can we rephrase this paragraph to:
"Run the convert artwork algorithm with init’s artwork as input and create a frozen array from the result, then set it to chapterInfo’s artwork images." ?
Do we need to change the other places? For this sentence "When the convert artwork algorithm with input parameter is invoked, the user agent MUST run the following steps:", isn't input
the init's artwork list which need to be parsed with the algorithm? And then it can generate the output list?
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.
Clicking on the link in "For each entry in input’s artwork" reveals the expected type of input
to be MediaMetadataInit. I.e. A's B is a deref. To take a sequence, e.g. artwork instead of {artwork}, it needs to say "For each entry in input".
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.
Changed to "For each entry in input (which is a MediaImage list), perform the following steps:"
Co-authored-by: François Daoust <[email protected]>
Co-authored-by: Jan-Ivar Bruaroey <[email protected]>
explainer.md
Outdated
[Exposed=Window] | ||
interface ChapterInformation { | ||
attribute DOMString title; | ||
attribute double startTime; |
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.
Should these two be readonly?
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.
Done.
|
||
dictionary ChapterInformationInit { | ||
DOMString title = ""; | ||
double startTime = 0; |
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.
What happens if there are two chapter information with the same startTime?
Should we define which one is selected using the sequence order?
Also, it seems we somehow expect that the web page provides a sequence ordered by startTime but I would guess it is fine to not do so.
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 it is unlikely that there will be more than one chapter with the same start time. However, if this does occur, we can simply use the chapter list as normal and sort it by start time after we have obtained it. Because the image sources are associated with each chapterInformation, there should be no problems regardless of the order in the list. Then in the UI, some chapters with the same start time will be displayed next to each other.
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.
Agreed this is an edge case, let's make sure that even these corner cases get implemented in an interoperable manner. So if we have to use list order to disambiguate, let's define it 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.
I'm thinking the website should be able to set whatever information is with the media. Even if there are two or more chapters with the same start time, there should be no order from them because they all refer to the same point in the video. Also, would it be better to leave this up to the client side? When the client receives a list of chapters, they can order them by start time first. Then, it is up to them whether or not to display them in any order. WDYT?
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.
Hey youennf, we're moving forward with submitting this pull request. Please feel free to open an issue later if you still have any additional questions about this change. Thanks :]
}; | ||
|
||
dictionary MediaMetadataInit { | ||
DOMString title = ""; | ||
DOMString artist = ""; | ||
DOMString album = ""; | ||
sequence<MediaImage> artwork = []; | ||
sequence<ChapterInformationInit> chapterInfo = []; |
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.
This whole section is somehow redundant with web idl.
Since we use ChapterInformationInit, it seems to make sense to add it there as well, since it seems this would be the only one missing here.
index.bs
Outdated
Run the <a>convert artwork algorithm</a> with <var>init</var>'s | ||
{{ChapterInformationInit/artwork}} as <var>input</var> and set | ||
<var>chapterInfo</var>'s <a for="ChapterInformation">artwork images</a> to the | ||
result of [=Create a frozen array|creating a frozen array=] from the result. |
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.
This is good as is I think but it could be made slightly clearer by splitting in two steps:
- Let artWork be the result of running the convert artwork algorithm ...
- Set chapterInfo.... to the result of creating a frozen array from artWork.
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.
Done.
@youennf Thanks for the review! |
Hi @youennf, can you PTAL at the latest patchset and see if you have more comments? The corresponding change is already landed under blink/. |
SHA: c7a47fb Reason: push, by steimelchrome Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Added a
ChapterInformation
attribute in theMediaMetadata
to carry the Youtube video chapter data:1) title of the section 2)timestamp of this section 3)screenshot image data of this sectionPreview | Diff