939 Commits

Author SHA1 Message Date
sheenachhabra
a1fc4e766f Reduce Exoplayer load control buffer durations for Transformer demo app
The default value is 50 seconds.
Changed it to 5 seconds.

This prevents the player from buffering too much data and causing the app to crash due to OOM.

This was reported in https://github.com/androidx/media/issues/1506

PiperOrigin-RevId: 649054885
2024-07-03 06:41:52 -07:00
tianyifeng
0510370bd2 Add OptIn annotation to method declaration in demo app file
#cherrypick

PiperOrigin-RevId: 648641357
2024-07-02 02:19:18 -07:00
simakova
16ef63cdfc Update the composition README file
PiperOrigin-RevId: 648282532
2024-07-01 01:34:17 -07:00
andrewlewis
dcbded0fa9 Rename cancel to pause in Transformer demo
The user might expect this button to back out to the configuration activity,
but actually it toggles pause/resume (though `cancel` is the method called).

PiperOrigin-RevId: 647273416
2024-06-27 04:59:13 -07:00
claincly
9e7318e3b4 Clarify the HDR10 video in the demos is actually HDR10+
It's captured on a Samsung and has dynamic metadata.

PiperOrigin-RevId: 646796836
2024-06-26 03:02:00 -07:00
okunhardt
bb568b5150 In DemoUtil, don't set cookie handler when using HttpEngineDataSource.
HttpEngine does not support cookie storage.

#cherrypick

PiperOrigin-RevId: 646084702
2024-06-24 07:21:08 -07:00
okunhardt
e591c37b1e Use HttpEngineDataSource when supported in demo app.
HttpEngineDataSource is the recommended HttpDataSource when it is available. It uses the [HttpEngine](https://developer.android.com/reference/android/net/http/HttpEngine).

#cherrypick

PiperOrigin-RevId: 646051562
2024-06-24 04:52:15 -07:00
simakova
d16004781e Remove AspectRatioFrameLayout usage from transformer demo
Removing unnecessary usage from transformer demo

PiperOrigin-RevId: 645426871
2024-06-21 10:18:30 -07:00
simakova
52bd9a2815 Add an option to include background audio sequence in Composition.
PiperOrigin-RevId: 645100835
2024-06-20 11:29:28 -07:00
ibaker
cb8f87e05e Remove direct AspectRatioFrameLayout usage from session demo
This class is a lower-level UI component that isn't directly needed if
apps are using `PlayerView` to handle their video output (it is used as
an implementation detail of `PlayerView`).

Removing its unecessary usages from this demo avoids developers copying
this as an example when building their own apps.

#cherrypick

PiperOrigin-RevId: 644972454
2024-06-20 04:06:23 -07:00
michaelkatz
ed07ac5d7d Fix linter errors in DemoMediaLibrarySessionCallback.kt
PiperOrigin-RevId: 644002147
2024-06-17 07:37:00 -07:00
sheenachhabra
4f691a7c02 Add a checkbox to use Media3 muxer in Transformer demo app
PiperOrigin-RevId: 642941439
2024-06-13 04:49:17 -07:00
tonihei
ebe74daaec Add image samples and track selection to demo app
Also move the track selection header strings to the demo app
as they are only used there (except for audio, which stays in UI)

PiperOrigin-RevId: 642616037
2024-06-12 08:02:52 -07:00
bachinger
efff1ee2f1 Add SessionError and use it in service results
This change adds `SessionError` and uses it in `SessionResult`
and `LibraryResult` to report errors to callers.

Constructors and factory method that used a simple `errorCode` to
construct error variants of `SessionResult` and `LibraryResult`
have been overloaded with a variant that uses a `SessionError`
instead. While these methods and constructors are supposed to be
deprecated, they aren't yet deprecated until the newly added
alternative is stabilized.

PiperOrigin-RevId: 642254336
2024-06-11 06:53:42 -07:00
andrewlewis
a1f21d976c Rename "preset file" to just "preset" in transformer demo
The new name means we can add streams and other sources that aren't files in
future, for example, screen recording input.

PiperOrigin-RevId: 641894319
2024-06-10 07:31:43 -07:00
andrewlewis
34966f5d86 Tidy passing views in transformer demos
PiperOrigin-RevId: 641891515
2024-06-10 07:18:12 -07:00
andrewlewis
cc046d5ce7 Remove most nullness marking from Transformer demos
The nullness checking is very verbose and redundant in some places, for
example, the ensures-non-null marking in the transformer activity, and it makes
changing features in the demo app more time consuming. The cost/benefit balance
seems to be in favor of removing this for demo code.

Note: the ExoPlayer main demo has nullness checks turned off.
PiperOrigin-RevId: 641890618
2024-06-10 07:14:10 -07:00
simakova
5e1bc6aa4f Rename "preset file" to "preset" in composition demo.
This change is made for consistency with transformer demo.

PiperOrigin-RevId: 641835714
2024-06-10 02:48:27 -07:00
jbibik
009f7360c5 Remember Player instance on recompositions
PiperOrigin-RevId: 641823733
2024-06-10 01:51:18 -07:00
jbibik
7b1a0376ad Add PlayerSurface Compose component
Underneath, it delegates to either
* `AndroidExternalSurface` (equivalent of SurfaceView), which is generally better for power and latency
* `AndroidEmbeddedExternalSurface` (equivalent of TextureView) which is better for interactions with other widgets or applying visual effects through the graphicsLayer

Note: the resulting surface is stretched across the whole screen. Aspect ratio handling will be addressed in the follow-up changes.
PiperOrigin-RevId: 641285482
2024-06-07 10:15:13 -07:00
dancho
9c4a532d5c Add LanczosResample effect to scale videos in Transformer
Add SeparableConvolution.configure(inputSize) to allow effect configuration
depending on input dimensions.
Add LanczosResample.scaleToFit method to scale input images to fit inside
given dimensions.

PiperOrigin-RevId: 640498008
2024-06-05 06:00:25 -07:00
samrobinson
304b784314 Add an analyzer mode option to Transformer demo.
PiperOrigin-RevId: 639746452
2024-06-03 05:33:28 -07:00
simakova
dbeb412355 Move effect final values and preset names and paths to arrays file.
PiperOrigin-RevId: 639034630
2024-05-31 07:59:03 -07:00
ibaker
1329821a35 Use kotlinx-coroutines-guava in session demo app
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
2024-05-31 01:28:47 -07:00
ibaker
68c16782d7 Migrate buildConfig from properties.gradle to build.gradle
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
2024-05-23 07:40:46 -07:00
kimvde
72ba3554a9 Set image duration on all media types
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
2024-05-22 01:41:50 -07:00
michaelkatz
cefc4dcd77 Add OptIn annotations to declarations in demo app files
#minor-release

PiperOrigin-RevId: 635469477
2024-05-20 08:56:30 -07:00
dancho
b9ec24a269 Fix AV sync for sequences with audio track shorter than video
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
2024-05-17 06:54:39 -07:00
samrobinson
d83e81f374 Add toggle for DebugTraceUtil to Transformer demo.
PiperOrigin-RevId: 634495944
2024-05-16 12:41:18 -07:00
ibaker
0e5a5e0294 Publish CompositionPlayer for playing compositions
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
2024-05-15 05:55:08 -07:00
ibaker
8dfcf025d9 Remove @UnstableApi from demo apps
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
2024-05-15 02:00:13 -07:00
ibaker
4cbe963b86 Tweak session demo UI strings
* 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
2024-05-14 05:34:00 -07:00
ibaker
b182e469f6 Standardise leak canary version in constants.gradle
PiperOrigin-RevId: 633505366
2024-05-14 02:51:23 -07:00
sheenachhabra
3a3145521b Replace Transformer.Muxer interface with Muxer.Muxer
PiperOrigin-RevId: 633193701
2024-05-13 06:54:19 -07:00
tonihei
6ac60c6dff Disable enhanced Java 8 desugaring
This avoids that apps have to depend on this additional config

Issue: androidx/media#1312
PiperOrigin-RevId: 631447767
2024-05-07 09:26:36 -07:00
tonihei
16df05ec29 Upgrade Gradle and AGP
The newer versions include a bugfix that automatically highlights
when our project requires enhanced Java 8 desugaring.

Issue: androidx/media#1312
PiperOrigin-RevId: 631373018
2024-05-07 04:20:55 -07:00
tonihei
74bb4ac98d Fix lint errors in shortform demo app
PiperOrigin-RevId: 629080780
2024-04-29 08:50:06 -07:00
bachinger
09f2cda43c Promote IMA DAI API to stable
PiperOrigin-RevId: 626064956
2024-04-18 09:49:48 -07:00
Copybara-Service
236c341168 Merge pull request #1266 from hubert-mazur:looped_playback
PiperOrigin-RevId: 625260110
2024-04-16 02:54:47 -07:00
ibaker
c01babe9bb Log JSON loading exception in demo app
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
2024-04-16 02:24:17 -07:00
Marc Baechinger
a6b540545d Minor cleanup 2024-04-16 10:54:45 +02:00
Marc Baechinger
ee6961f958 Format with google-java-format 2024-04-15 10:54:49 +02:00
Hubert Mazur
e41f76ea85 Introduce a new optional argument for repeat mode
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.
2024-04-15 10:54:49 +02:00
tianyifeng
8867642681 Use DefaultPreloadManager in shortform demo app
The `MediaSourceManager` is removed and its functionalities are replaced by `DefaultPreloadManager`.

PiperOrigin-RevId: 621884502
2024-04-04 09:39:23 -07:00
bachinger
617f9898c3 Add isPlaybackOngoing and stopMediaSessionService
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
2024-04-04 09:01:55 -07:00
tofunmi
896d147444 Overlay: fix the overlay anchor translation
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
2024-04-03 11:27:43 -07:00
jbibik
98b0d24379 Add a new empty Compose Demo as a skeleton
PiperOrigin-RevId: 620020593
2024-03-28 12:30:20 -07:00
sheenachhabra
8d65b75185 Rename setFragmentedMp4Enabled to setOutputFragmentedMp4
PiperOrigin-RevId: 619216854
2024-03-26 09:34:23 -07:00
sheenachhabra
2eaece5ed9 Move setMaxDelayBetweenSamplesMs on Transformer builder
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
2024-03-25 11:02:15 -07:00
tianyifeng
2c8d07c2dd Inform DefaultPreloadManager when player uses PreloadMediaSource
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
2024-03-18 04:54:49 -07:00