I originally tried switching to `Futures.addCallback` (as a follow-up
to Issue: androidx/media#890), but it seemed like a good chance to go further into
Kotlin-ification.
Before this change, if the connection to the session failed, the app
would hang at the 'waiting' screen with nothing logged (and the music
keeps playing). This behaviour is maintained with the `try/catch` around
the `.await()` call (with additional logging). Without this, the failed
connection causes the `PlayerActivity` to crash and the music in the
background stops. The `try/catch` is used to flag to developers who
might be using this app as an example that connecting to the session
may fail, and they may want to handle that.
This change also switches `this.controller` to be `lateinit` instead of
nullable.
Issue: androidx/media#890
PiperOrigin-RevId: 638948568
This is generated in response to a deprecation warning in AS:
```
The option setting 'android.defaults.buildfeatures.buildconfig=true' is deprecated.
The current default is 'false'.
It will be removed in version 9.0 of the Android Gradle plugin.
You can resolve this warning in Android Studio via `Refactor` > `Migrate BuildConfig to Gradle Build Files`
```
PiperOrigin-RevId: 636546985
This was previously only set on images because it was not ignored on
other media types. This parameter was made no-op for non-images in
7b2a1b4443.
PiperOrigin-RevId: 636078142
For each item, AudioGraphInput now pads the input audio track with silence
to the duration given in onMediaItemChanged.
Possibly resolves Issue: androidx/media#921 .
PiperOrigin-RevId: 634753721
This class is not ready for production app usage yet, so it is still
marked `@RestrictTo(LIBRARY_GROUP)` for now. Apps can experiment with it
in a non-prod context by suppressing the associated lint error.
* Issue: androidx/media#1014
* Issue: androidx/media#1185
* Issue: androidx/media#816
PiperOrigin-RevId: 633921353
This annotation is only needed on public classes that are part of a
distributed library.
Switch to `@OptIn` for the one file where `@UnstableApi` was
suppressing lint errors.
PiperOrigin-RevId: 633858516
* Consistently use 'playlist' instead of 'play list'
* Remove wording about 'playlist loading' since when this message is
shown the music is already playing in the background, we're just
waiting for the in-app controller to connect to the background
service.
PiperOrigin-RevId: 633550729
The newer versions include a bugfix that automatically highlights
when our project requires enhanced Java 8 desugaring.
Issue: androidx/media#1312
PiperOrigin-RevId: 631373018
This change also switches from media3's `Log` class (marked with
`@UnstableApi`) to `android.util.Log` which is what we would expect
apps to use.
Issue: androidx/media#1283
PiperOrigin-RevId: 625252745
Add a new string command line optional argument to allow the playback
to run in loop. This would help to use the app in the automated video
tests. The change does not enable the option view for switching the loop
mode in the UI as providing an extra argument implies force, not
optional, loop playback. The extra option is provided with "repeat_mode"
key and one of the possible modes can be specified: NONE|ONE|ALL. The
available options correspond to the Player API to ensure compability.
This API additions help an app to implement the lifecycle of a MediaSessionService
properly and in consistency with the `MediaSessionService` being in the foreground
or not.
Not properly implementing `onTaskRemoved` is the main reason for crashes and
confusion. This change provides `MediaSessionService` with a default
implementation that avoids crashes of the service. This default implementation
uses the new API provided with this change just as an app can do.
Issue: androidx/media#1219
PiperOrigin-RevId: 621874838
Makes OverlayFrameAnchor works as described in the OverlaySettings documentation. Currently the code does the opposite e.g setting the anchor to (+1,-1) makes the code anchor to the top left rather than the bottom right.
PiperOrigin-RevId: 621585558
This property is transformer specific and does not belong to
muxer interface.
This is to eventually replace muxer interface in Transformer module with
muxer interface in Muxer module.
PiperOrigin-RevId: 618895836
Add a new method `onUsedByPlayer(PreloadMediaSource)` for `PreloadMediaSource.PreloadControl`, which will be invoked when the player starts to use the `PreloadMediaSource`, or calling `PreloadMediaSource.preload` while the player is already using that source. `DefaultPreloadManager` will immediately preload the next source when receiving `onUsedByPlayer` event.
PiperOrigin-RevId: 616789121
Having a default icon available allows apps to only specify the
icon constant without having to define an icon drawable themselves
as Media3 can fill in the icon resource for backwards compatibility.
The switch util method allows R8 to easily remove unused icons, so
having default icons won't affect APK size unless the constants are
used to set up the CommandButtons.
PiperOrigin-RevId: 614623909
Also put back a comment in DownloadTracker that is still relevant on API 19.
Also deprecate PlaceholderSurface.newInstanceV17() in favour of just
newInstance()
Since Kotlin 2.0 the compiler became better at detecting incorrect
annotation applications. The @OptIn annotation can't be applied to an
expression, so when compiling with Kotlin 2.0 it results in an error.
PiperOrigin-RevId: 604596657
The `MediaMuxer` (FrameworkMuxer) supports AV1 mime type from API 34.
For this to work track `Format/MediaFormat` must have `CSD`
data.
Change also include providing AV1 option in demo app.
Transmuxing of an AV1 mime type input will not work because
`Extractor` does not extract AV1 CSD data.
Verified changes manually via demo app.
PiperOrigin-RevId: 603002380
Many usages are needed to support other deprecations and some
can be replaced by the recommended direct alternative.
Also replace links to deprecated/redirected dev site
PiperOrigin-RevId: 601795998
It's useful for development and debugging to select a local image
or audio (only) file as well as a video file in the transformer demo
app.
I tested manually that you can select a local video, audio and image
but not e.g. a pdf with the main "choose local file" picker and only
an image with the choose local image picker for the bitmap overlay
demo.
PiperOrigin-RevId: 600722622
Originally a `PlayerId` has to be passed and it should be the same id of the player who is going to play the sources, but it turns out to be unnecessary.
When preloading, we can set a `PlayerId.UNSET` inside of the `PreloadMediaSource`, as there is no ongoing playback. And when the source is handed over to player, player will set the player's `PlayerId`.
PiperOrigin-RevId: 597475119
The `PlaybackService` of the demo app is declared
as `androidx.media3.session.MediaSessionService` instead
of `androidx.media3.session.MediaLibraryService`. While
this technically works, its confusing to do that in the
demo app.
Generally, apps that declare the legacy
`android.media.browse.MediaBrowserService` should also
declare `androidx.media3.session.MediaLibraryService`
and the demo app should reflect this common case.
Issue: androidx/media#672
PiperOrigin-RevId: 595320994
For out of order B-frames, the samples comes out of order and hence
presentation timestamps are not strictly increasing.
This can be verified by adding following assertion in `writeSampleData()` API
either in `MuxerWrapper` or in `Muxer API`.
```
checkArgument(
bufferInfo.presentationTimeUs > lastSamplePresentationTimeUs,
"Out of order B-frames are not supported");
```
PiperOrigin-RevId: 589152093