You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The motivating example for this issue is that MediaItem.Builder#setDrmSessionForClearPeriods() is silently ignored if MediaItem.Builder#setDrmUuid() is not set (#8842 (comment)).
From an implementation details perspective it's understandable that the UUID is required for any of the other DRM fields to be useful, but the silent dropping of the value (rather than failing during build()) leads to confusing behaviour for users of the API who believe they're calling a method and have no indication it's having no effect.
This issue tracks changing MediaItem.Builder to more aggressively fail during build() if some setters have been called that are going to be ignored.
This isn't limited to the DRM fields, there are many other examples (the javadoc has lots of text like "If setUri(java.lang.String) is passed a non-null uri, the MIME type is used to create a MediaItem.PlaybackProperties object. Otherwise it will be ignored.").
Some apps may be (intentionally or unintentionally) depending on the existing silently-drop behaviour, so we may need to consider making this change gradually, e.g. by introducing a buildStrict() method which fails loudly and deprecating the silently-ignoring build() method. (this specific example is a shame because we'd really like to end up in a final state where the method is called build() (since that seems like obviously the correct name) - so it might be enough to instead change the behaviour of build() and introduce a temporary buildLenient() method with the 'old' behaviour that apps can switch to if they observe problems with the strict behaviour).
The text was updated successfully, but these errors were encountered:
Many of the setters are ignored unless others are set - this change:
* Lists these conditions exhaustively.
* Uses more concise language to avoid overshadowing the main details
of what the setter sets.
* Tweaks the language from 'is ignored' to 'shouldn't be called', to
open up the future possibility of throwing an error if these are
called without the 'required' setter also being present (see
Issue: #8957).
#minor-release
PiperOrigin-RevId: 376162385
Many of the setters are ignored unless others are set - this change:
* Lists these conditions exhaustively.
* Uses more concise language to avoid overshadowing the main details
of what the setter sets.
* Tweaks the language from 'is ignored' to 'shouldn't be called', to
open up the future possibility of throwing an error if these are
called without the 'required' setter also being present (see
Issue: #8957).
#minor-release
PiperOrigin-RevId: 376162385
The MediaItem.Builder class structure has now been changed to make it harder/impossible to create 'impossible' configurations - because most required fields are now passed into the constructor of the relevant sub-builder. I don't think there's any additional work to do here.
The motivating example for this issue is that
MediaItem.Builder#setDrmSessionForClearPeriods()
is silently ignored ifMediaItem.Builder#setDrmUuid()
is not set (#8842 (comment)).From an implementation details perspective it's understandable that the UUID is required for any of the other DRM fields to be useful, but the silent dropping of the value (rather than failing during
build()
) leads to confusing behaviour for users of the API who believe they're calling a method and have no indication it's having no effect.This issue tracks changing
MediaItem.Builder
to more aggressively fail duringbuild()
if some setters have been called that are going to be ignored.This isn't limited to the DRM fields, there are many other examples (the javadoc has lots of text like "If setUri(java.lang.String) is passed a non-null uri, the MIME type is used to create a MediaItem.PlaybackProperties object. Otherwise it will be ignored.").
Some apps may be (intentionally or unintentionally) depending on the existing silently-drop behaviour, so we may need to consider making this change gradually, e.g. by introducing a
buildStrict()
method which fails loudly and deprecating the silently-ignoringbuild()
method. (this specific example is a shame because we'd really like to end up in a final state where the method is calledbuild()
(since that seems like obviously the correct name) - so it might be enough to instead change the behaviour ofbuild()
and introduce a temporarybuildLenient()
method with the 'old' behaviour that apps can switch to if they observe problems with the strict behaviour).The text was updated successfully, but these errors were encountered: