962 Commits

Author SHA1 Message Date
ibaker
869a91bba8 Remove DemoUtil.ALLOW_CRONET_FOR_NETWORKING
This boolean only exists to be changed in source, but it is now used
as part of a 3-way fallback logic (since adding `HttpEngine`
integration), so it's not really more convenient or clearer to change
this constant than just hack the code of `getHttpDataSourceFactory`
directly.

PiperOrigin-RevId: 677834348
2024-09-23 09:55:55 -07:00
samrobinson
b4436c523c Migrate Media3 EditedMediaItemSequence usages to the Builder.
Removed the unnecessary wrapping of items in an ImmutableList.

PiperOrigin-RevId: 677796662
2024-09-23 08:06:55 -07:00
Gaëtan Muller
76e3fc06dd
Update activity_main.xml 2024-09-19 11:08:06 +02:00
ibaker
3e8ecbf564 Remove @DoNotInline annotations
This is no longer needed now our `compileSdk` implies a new-enough AGP
which does this out-lining automatically via R8. See also
https://issuetracker.google.com/345472586#comment7

There's no plan to remove the `ApiXXX` classes, but no new ones need
to be added.

PiperOrigin-RevId: 675940634
2024-09-18 04:47:39 -07:00
tianyifeng
72ae454f67 Use buffered duration from start position to control preload progress
`PreloadMediaSource` allows to have a `startPositionUs` passed when `preload` is called, then in `PreloadControl.onContinueLoadingRequested`, it can be more intuitive to see the buffered duration rather than the absolute buffered position as the preload progress. Similar in `DefaultPreloadManager`, we haven't allowed the apps to set a custom start position for individual sources though, once we add this support, using the "duration from the start position" than the absolute position will be less error-prone, otherwise, it can run into a case that the position that the apps set is smaller than the start position.

PiperOrigin-RevId: 674251362
2024-09-13 05:05:39 -07:00
ktrajkovski
63b45b7503 Build IAMF libraries with gradle and ndk-build.
In order to support building with `gradle` a new `build.gradle` file was added together with `Android.mk`, `Application.mk`, and `libiamf.mk` necessary for local builds with NDK.

After this change, IAMF files may also be played in the ExoPlayer demo built locally (without blaze).

PiperOrigin-RevId: 664841684
2024-08-19 09:29:47 -07:00
simakova
2d527b08c3 Toggle video effects in the composition demo.
Add an option to enable or disable video effects in preview or export.

PiperOrigin-RevId: 662488658
2024-08-13 06:14:22 -07:00
jbibik
9ace81bf2f Move PlayerExtensions into common-ktx module
For now, the only extension function on the `Player` has been used in a Compose demo. It can be promoted to a proper module where in the future other extension functions will reside. Given that `Player` is in `androidx.media3.common`, the corresponding KTX library for it is `androidx.media3.common-ktx`

To start using the new `suspend fun listen`, one must add `androidx.media3:media3-common-ktx` as a Gradle dependency and `import androidx.media3.common.listen`

PiperOrigin-RevId: 658771029
2024-08-02 06:24:10 -07:00
jbibik
61e68d3f24 Add Kotlin extension function on Player
Given that `Player` interface is written in Java and is has a callback-based Listener interface, we need an adapter for the Kotlin-native world.

This change introduces a suspending function `listen` that creates a coroutine, in order to capture `Player.Events`.

PiperOrigin-RevId: 658478608
2024-08-01 11:41:11 -07:00
Googler
4a99dc4c94 Reserve space for the skip buttons in the media3 demo
This is to avoid the shuffle custom action jumping around when skipping to the first or last item of a playlist.

PiperOrigin-RevId: 657925696
2024-07-31 02:31:03 -07:00
ktrajkovski
04bfeec751 Add decoding functions to IamfDecoder and LibiamfAudioRender.
PiperOrigin-RevId: 657621223
2024-07-30 09:33:31 -07:00
Enrique López Mañas
debea15bdf chore: fixed links 2024-07-26 12:21:31 +00:00
Enrique López Mañas
b93cc68a67 chore: updated docs and broken links 2024-07-26 12:21:31 +00:00
Ian Baker
8c79a8fed2 Remove tools:replace="android:name" from manifests where multidex config has been removed 2024-07-25 13:12:10 +01:00
Gaëtan Muller
71b8c32a6f Remove Multidex 2024-07-24 16:17:00 +01:00
Gaëtan Muller
e1633ff03b Remove unnecessary targetApi 2024-07-24 16:17:00 +01:00
Gaëtan Muller
64eedceb8c Use project.ext.minSdkVersion everywhere 2024-07-24 16:17:00 +01:00
bachinger
076bc451f2 Update Kotlin Gradle plugin to version 1.9.10.
According to b/292763081 the build failure
`unresolved reference: addLast` in the session-demo is caused
by a bug in the Kotlin compiler 1.9.0 to which we depend.

Bumping the Kotlin plugin version to 1.9.10 which is the next
above 1.9.0 as listed in [1], the build problem is resolved.

Further, the Kotlin extension compiler version is set to 1.5.3
to make compose work with Kotlin 1.9.10 (see [2] for the
Kotlin/Compose compatibility map).

[1] https://kotlinlang.org/docs/releases.html#release-details
[2] https://developer.android.com/jetpack/androidx/releases/compose-kotlin

PiperOrigin-RevId: 654030537
2024-07-19 09:33:41 -07:00
samrobinson
d0afb96c40 Implement repeat mode for CompositionPlayer.
-----

Context:
* Each sequence is wrapped as a single MediaSource, each being played
by an underlying ExoPlayer.
* Repeat mode is typically implemented in Players as a seek to the next
item in the playlist.

-----

This CL:

Repeat mode is triggered by listening for when the main input player
sees a play when ready change due to the end of the media item.

There is a slight delay at the end of the playback, before it repeats.
Setting repeat mode on the underlying players addresses this, but means
that the players will seek without waiting for the CompositionPlayer,
and as such previewAudioPipeline does not get the correct signals
around blocking/flushing.

PreviewAudioPipeline - The seek position can validly be C.TIME_UNSET,
however preview pipeline did not handle this case.

CompositionPlayer getContentPosition is given (through a lambda) as a
supplier to the State object, which means any comparisons between
previous/new state for this value does not work. In SimpleBasePlayer,
there is logic to use the positionDiscontinuityPositionUs for the
position change (see getPositionInfo called from
updateStateAndInformListeners), however this logic is not considered in
getMediaItemTransitionReason, so a condition needed to be added for
this case.

-----

Tests:
* Dump files clearly show the position and data is repeated.
* Assertions on the reasons for transitions or position
discontinuities.
PiperOrigin-RevId: 653210278
2024-07-17 06:22:02 -07:00
ibaker
6a9ff95bf0 Bump minSdk to 21 and remove resulting simple dead code
All other AndroidX libraries have already increased their min SDK to
21.

This change renames private symbols to remove `V21` suffixes and
similar, but doesn't change public or protected symbols with similar
names, to avoid needless breakages/churn on users of the library.

Some of the dead code removal is more complex, so I've split it out
into follow-up changes to make it easier to review.

PiperOrigin-RevId: 651776556
2024-07-12 08:11:01 -07:00
ibaker
00d1e70a34 Rollback of 91633e6ae3
PiperOrigin-RevId: 650620012
2024-07-09 07:29:57 -07:00
ibaker
5dd377fb7b Rollback of 91633e6ae3
PiperOrigin-RevId: 650312000
2024-07-08 11:15:18 -07:00
okunhardt
91633e6ae3 Update HttpEngineDataSource to require at least S extension 7.
This earlier version supports [HttpEngine](https://developer.android.com/reference/android/net/http/HttpEngine) and thus this change allows more devices to use HttpEngine.

This fixes Issue: androidx/media#1262, which suggests to do this.

PiperOrigin-RevId: 650224711
2024-07-08 06:13:24 -07:00
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