-
Notifications
You must be signed in to change notification settings - Fork 429
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
Add helper method to convert platform MediaSession.Token to media3 session Token #171
Comments
This is more of less correct when going from a platform There is already a method to convert the
Would it help to have a similar method converting Not sure if relevant to your use case, but it's also possible to directly query all existing media3 sessions associated with a service using this method:
Note that this list doesn't include sessions that are not associated to a service ( MediaSessionService or MediaLibraryService or MediaBrowserServiceCompat ).
|
If the idea of the media3 library is to progressively phase out the need of the other older media support library, I think it would be good to have a method to directly convert I saw the To explain better our use case, we have a bluetooth companion app, and our users are able to control music played on the Android phone, directly from the watches. Our Android app forwards the media session information from Android to the watches and the inverse is true for the commands (play/pause/skip etc.). We aim to have an implementation that works with as many Android music/media applications as possible. |
Agree, I'll convert this to an enhancement.
That's interesting. I wonder if we need the equivalent of
Isn't this expected if you don't have permission to access these sessions? |
We have permissions to access notifications and we can trigger theirs actions. Controlling any app through the session tokens retrieved from the |
This avoids that apps have to depend on the legacy compat support library when they want to make this conversion. Also add a version to both helper methods that takes a Looper to give apps the option to use an existing Looper, which should be much faster than spinning up a new thread for every method call. Issue: #171 PiperOrigin-RevId: 490441913
This avoids that apps have to depend on the legacy compat support library when they want to make this conversion. Also add a version to both helper methods that takes a Looper to give apps the option to use an existing Looper, which should be much faster than spinning up a new thread for every method call. Issue: #171 PiperOrigin-RevId: 490441913 (cherry picked from commit 03f0b53)
* Reorder some release notes in other sections. #minor-release PiperOrigin-RevId: 490224795 (cherry picked from commit fa531b79249e5435af719bfbe168b999b5032b47) * Fix compilation error in ffmpeg JNI layer PiperOrigin-RevId: 490263003 (cherry picked from commit a9be38a339161c9a286c496ba48cdde1d1db5fdc) * Changed decoder list sort to order by functional support of format Added new method to check if codec just functionally supports a format. Changed getDecoderInfosSortedByFormatSupport to use new function to order by functional support. This allows decoders that only support functionally and are more preferred by the MediaCodecSelector to keep their preferred position in the sorted list. Unit tests included -Two MediaCodecVideoRenderer tests that verify hw vs sw does not have an effect on sort of the decoder list, it is only based on functional support. Issue: google/ExoPlayer#10604 PiperOrigin-RevId: 487779284 (cherry picked from commit fab66d972ef84599cdaa2b498b91f21d104fbf26) * Update targetSdkVersion of demo session app to appTargetSdkVersion PiperOrigin-RevId: 488884403 (cherry picked from commit cfe36af8478e78dd6e334298bcee425c61a9ba2a) * Add bundling exclusions with unit tests The exclusion will be used in a follow-up CL when sending PlayerInfo updates. #minor-release PiperOrigin-RevId: 488939258 (cherry picked from commit bae509009bd62554876ecb7485708e50af4eaa2a) * Fix NPE when listener is not set PiperOrigin-RevId: 488970696 (cherry picked from commit f3ed9e359dfdff2a99bf8766ffceb59a93d1bc93) * Add setPlaybackLooper ExoPlayer builder method The method allows clients to specify a pre-existing thread to use for playback. This can be used to run multiple ExoPlayer instances on the same playback thread. PiperOrigin-RevId: 488980749 (cherry picked from commit e1fe3120e29a66ac2dcde6e9960756197bac6444) * Load bitmaps for `MediaBrowserCompat`. * Transforms the `ListenableFuture<LibraryResult<MediaItem>>` and `ListenableFuture<LibraryResult<List<MediaItem>>>` to `ListenableFuture<MediaBrowserCompat.MediaItem>` and `ListenableFuture<List<MediaBrowserCompat.MediaItem>>`, and the result will be sent out when `ListenableFuture` the `MediaBrowserCompat.MediaItem` (or the list of it) is fulfilled. * Add `artworkData` to the tests in `MediaBrowserCompatWithMediaLibraryServiceTest`. PiperOrigin-RevId: 489205547 (cherry picked from commit 4ce171a3cfef7ce1f533fdc0b7366d7b18ef44d1) * Mark broadcast receivers as not exported They are called from the system only and don't need to be exported to be visible to other apps. PiperOrigin-RevId: 489210264 (cherry picked from commit 22ccc1a1286803868970fb2b1eafe63e9c669a5c) * Throw exception if a released player is passed to TestPlayerRunHelper I considered moving this enforcement inside the ExoPlayerImpl implementation, but it might lead to app crashes in cases that apps (incorrectly) call a released player, but it wasn't actually causing a problem. PiperOrigin-RevId: 489233917 (cherry picked from commit cba65c8c61122c5f0a41bd95a767002e11a1bae4) * Add additional codecs to the eosPropagationWorkaround list. Issue: google/ExoPlayer#10756 PiperOrigin-RevId: 489236336 (cherry picked from commit d1b470e4cc26a15525b583d1953529c8ec73a950) * Pass correct frame size for passthrough playback When estimating the AudioTrack min buffer size, we must use a PCM frame of 1 when doing direct playback (passthrough). The code was passing -1 (C.LENGTH_UNSET). PiperOrigin-RevId: 489238392 (cherry picked from commit 07d25bf41d9fa4d81daade6787a9b15682e9cf1f) * Add remaining state and getters to SimpleBasePlayer This adds the full Builders and State representation needed to implement all Player getter methods and listener invocations. PiperOrigin-RevId: 489503319 (cherry picked from commit 81918d8da7a4e80a08b65ade85ecb37c995934e7) * Do not require package visibility when connecting to a Media3 session When we currently call SessionToken.createSessionToken with a legacy token, we call the package manager to get the process UID. This requires visiblity to the target package, which may not be available unless the target runs a service known to the controller app. However, when connecting to a Media3, this UID doesn't have to be known, so we can move the call closer to where it's needed to avoid the unncessary visibility check. In addition, a legacy session may reply with unknown result code to the session token request, which we should handle as well. One of the constructor can be removed since it was only used from a test. PiperOrigin-RevId: 489917706 (cherry picked from commit 2fd4aac310787d1a57207b5142a0ab08d5e1a2a5) * Add `set -eu` to all shell scripts These flags ensure that any errors cause the script to exit (instead of just carrying on) (`-e`) and that any unrecognised substitution variables cause an error instead of silently resolving to an empty string (`-u`). Issues like Issue: google/ExoPlayer#10791 should be more quickly resolved with `set -e` because the script will clearly fail with an error like `make: command not found` which would give the user a clear pointer towards the cause of the problem. #minor-release PiperOrigin-RevId: 490001419 (cherry picked from commit 45b8fb0ae1314abdc5b0364137622214ac8e5b98) * Do not require package visibility when obtaining SessionTokens The only reason this is required at the moment is to set the process UID field in the token, that is supposed to make it easier for controller apps to identify the session. However, if this visibility is not provided, it shouldn't stop us from creating the controller for this session. Also docuement more clearly what UID means in this context. PiperOrigin-RevId: 490184508 (cherry picked from commit c41a5c842080a7e75b9d92acc06d583bd20c7abb) * Add `DefaultExtractorsFactory.setTsSubtitleFormats` ExoPlayer is unable to detect the presence of subtitle tracks in some MPEG-TS files that don't fully declare them. It's possible for a developer to provide the list instead, but doing so is quite awkward without this helper method. This is consistent for how `DefaultExtractorsFactory` allows other aspects of the delegate `Extractor` implementations to be customised. * Issue: google/ExoPlayer#10175 * Issue: google/ExoPlayer#10505 #minor-release PiperOrigin-RevId: 490214619 (cherry picked from commit ff48faec5f9230355907a8be24e44068ec294982) * Reorder some release notes in other sections. PiperOrigin-RevId: 490224795 (cherry picked from commit fa531b79249e5435af719bfbe168b999b5032b47) * Load bitmaps for `MediaSessionCompat.QueueItem`. When receiving the `onTimelineChanged` callback, we convert the timeline to the list of `QueueItem`s, where decoding a bitmap is needed for building each of the `QueueItem`s. The strategy is similar to what we did in <unknown commit> for list of `MediaBrowserCompat.MediaItem` - set the queue item list until the bitmaps decoding for all the `MediaItem`s are completed. PiperOrigin-RevId: 490283587 (cherry picked from commit 8ce1213ddddb98e0483610cfeaeba3daa5ad9a78) * Migrate BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS to Media3 PiperOrigin-RevId: 490376734 (cherry picked from commit 1803d1cdb8cf429c3d0a3fdbbecbad25145db8c4) * Add helper method to convert platform session token to Media3 token This avoids that apps have to depend on the legacy compat support library when they want to make this conversion. Also add a version to both helper methods that takes a Looper to give apps the option to use an existing Looper, which should be much faster than spinning up a new thread for every method call. Issue: androidx/media#171 PiperOrigin-RevId: 490441913 (cherry picked from commit 03f0b53cf823bb4878f884c055b550b52b9b57ab) * Merge pull request #10786 from TiVo:p-aacutil-test-impl PiperOrigin-RevId: 490465182 (cherry picked from commit a32b82f7bd14161b4ba204db28ca842f1dd0bb12) * Call future listener on the same handler that created the controller The direct executor is not the proper way to determine on what thread to run the `Future.Listener` and the `MediaControllerCreationListener` because the listener may call the controller passed as argument which must happen on the same thread that built the controller. This change makes sure this is the case. PiperOrigin-RevId: 490478587 (cherry picked from commit 68908be18d0a46478be05ad406a5027c15c38723) * Exclude tracks from `PlayerInfo` if not changed This change includes a change in the `IMediaController.aidl` file and needs to provide backwards compatibility for when a client connects that is of an older or newer version of the current service implementation. This CL proposes to create a new AIDL method `onPlayerInfoChangedWithExtensions` that is easier to extend in the future because it does use an `Bundle` rather than primitives. A `Bundle` can be changed in a backward/forwards compatible way in case we need further changes. The compatibility handling is provided in `MediaSessionStub` and `MediaControllerStub`. The approach is not based on specific AIDL/Binder features but implemented fully in application code. Issue: androidx/media#102 #minor-release PiperOrigin-RevId: 490483068 (cherry picked from commit 3d8c52f28d5d3ef04c14868e15036563a9fc662d) * Misc fix in gradle build file Issue: androidx/media#209 #minor-release PiperOrigin-RevId: 490492223 (cherry picked from commit 2424ee77926923fc1bf690e7e623ff9d57b9a200) * Handle the bitmap loading result with applicationHandler Before this change, the bitmap loading result with mainHandler, in which we set the metadata to `MediaSessionCompat`. However, the `MediaSessionCompat` is not thread safe, all calls should be made from the same thread. In the other calls to `MediaSessionCompat`, we ensure that they are on the application thread (which may be or may not be main thread), so we should do the same for `setMetadata` when bitmap arrives. Also removes a comment in `DefaultMediaNotificationProvider` as bitmap request caching is already moved to CacheBitmapLoader. PiperOrigin-RevId: 490524209 (cherry picked from commit 80927260fd46413b7d1efafed72360b10049af2a) * Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3 #minor-release PiperOrigin-RevId: 490527831 (cherry picked from commit 76df06a7a364c580dfe07d9f069237cd77c5174c) * Rollback of https://github.com/androidx/media/commit/76df06a7a364c580dfe07d9f069237cd77c5174c *** Original commit *** Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3 #minor-release *** PiperOrigin-RevId: 490570517 (cherry picked from commit 427329175e87a7f3173791c59e6c2d4c4ed8dea4) * Rollback of https://github.com/androidx/media/commit/427329175e87a7f3173791c59e6c2d4c4ed8dea4 *** Original commit *** Rollback of https://github.com/androidx/media/commit/76df06a7a364c580dfe07d9f069237cd77c5174c *** Original commit *** Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3 #minor-release *** *** PiperOrigin-RevId: 490707234 (cherry picked from commit 82711630ed1afbe7417aad95244a91135e24c27f) * Use `ParsableBitArray` instead of `ParsableByteArray` To avoid complicated bit shifting and masking. Also makes the code more readable. PiperOrigin-RevId: 490749482 (cherry picked from commit 3d31e094a9e802354dce2f3dc5f33062f7624248) * Convert bitrates to bps before setting it Format expects the values of `averageBitrate` and `peakBitrate` in bps and the value fetched from AC3SpecificBox and EC3SpecificBox is in kbps. PiperOrigin-RevId: 490756581 (cherry picked from commit 4066970ce7292642794f4a3954f8d0fde78dd310) * Remove flakiness from DefaultAnalyticsCollectorTest Our FakeClock generally makes sure that playback tests are fully deterministic. However, this fails if the test uses blocking waits with clock.onThreadBlocked and where relevant Handlers are created without using the clock. To fix the flakiness, we can make the following adjustments: - Use TestExoPlayerBuilder instead of legacy ExoPlayerTestRunner to avoid onThreadBlocked calls. This also makes the tests more readable. - Use clock to create Handler for FakeVideoRenderer and FakeAudioRenderer. Ideally, this should be passed through RenderersFactory, but it's too disruptive given this is a public API. - Use clock for MediaSourceList and MediaPeriodQueue update handler. PiperOrigin-RevId: 490907495 (cherry picked from commit 6abc94a8b7180979c520fc581310b87bf297b1bb) * Clean up javadoc on `Metadata.Entry.populateMediaMetadata` Remove self-links, and remove section that is documenting internal ordering behaviour of [`SimpleBasePlayer.getCombinedMediaMetadata`](https://github.com/google/ExoPlayer/blob/bb270c62cf2f7a1570fe22f87bb348a2d5e94dcf/library/common/src/main/java/com/google/android/exoplayer2/SimpleBasePlayer.java#L1770) rather than anything specifically about this method. #minor-release PiperOrigin-RevId: 490923719 (cherry picked from commit a6703285d0d1bedd946a8477cb68c46b1a097b09) * Ensure messages sent on a dead thread don't block FakeClock execution FakeClock keeps an internal list of messages to be executed to ensure deterministic serialization. The next message from the list is triggered by a separate helper message sent to the real Handler. However, if the target HandlerThread is no longer alive (e.g. when it quit itself during the message execution), this helper message is never executed and the entire message execution chain is stuck forever. This can be solved by checking the return values of Hander.post or Handler.sendMessage, which are false if the message won't be delivered. If the messages are not delivered, we can unblock the chain by marking the message as complete and triggering the next one. PiperOrigin-RevId: 491275031 (cherry picked from commit 8fcc06309323847b47ed8ab225cd861335448d36) * Merge pull request #10799 from OxygenCobalt:id3v2-multi-value PiperOrigin-RevId: 491289028 (cherry picked from commit b81d5f304e2f5fc55577e31c31ff6df5ce7d0ef5) * Split up `Id3DecoderTest` methods It's clearer if each test method follows the Arrange/Act/Assert pattern PiperOrigin-RevId: 491299379 (cherry picked from commit fc5d17832f90f36eb30ee0058204d110e27adcc9) * Remove impossible `UnsupportedEncodingException` from `Id3Decoder` The list of charsets is already hard-coded, and using `Charset` types ensures they will all be present at run-time, hence we will never encounter an 'unsupported' charset. PiperOrigin-RevId: 491324466 (cherry picked from commit 5292e408a6fd000c1a125519e22a7c18460eed59) * Merge pull request #10776 from dongvanhung:feature/add_support_clear_download_manager_helpers PiperOrigin-RevId: 491336828 (cherry picked from commit 3581ccde29f0b70b113e38456ff07167267b0ad9) * Bump cast sdk version and remove workaround for live duration The fix for b/171657375 (internal) has been shipped with 21.1.0 already (see https://developers.google.com/cast/docs/release-notes#august-8,-2022). PiperOrigin-RevId: 491583727 (cherry picked from commit 835d3c89f2099ca66c5b5f7af686eace1ac17eb8) * Add configuration to support OPUS offload To support OPUS offload, we need to provide a few configuration values that are currently not set due to the lack of devices supporting OPUS offload. PiperOrigin-RevId: 491613716 (cherry picked from commit 568fa1e1fa479fd1659abf1d83d71e01227ab9cf) * Use audio bitrate to calculate AudioTrack min buffer in passthrough Use the bitrate of the audio format (when available) in DefaultAudioSink.AudioTrackBufferSizeProvider.getBufferSizeInBytes() to calculate accurate buffer sizes for direct (passthrough) playbacks. #minor-release PiperOrigin-RevId: 491628530 (cherry picked from commit d12afe0596b11c473b242d6389bc7c538a988238) * Add public constructors to `DefaultMediaNotificationProvider` Issue: androidx/media#213 Without a public constructor, it is not possible to extend this class and override its method. PiperOrigin-RevId: 491673111 (cherry picked from commit f3e450e7833bbc62237c1f24f9a1f6c4eed21460) * Use the artist as the subtitle of the legacy media description The Bluetooth AVRCP service expects the metadata of the item currently being played to be in sync with the corresponding media description in the active item of the queue. The comparison expects the metadata values of `METADATA_KEY_TITLE` and `METADATA_KEY_ARTIST` [1] to be equal to the `title` and `subtitle` field of the `MediaDescription` [2] of the corresponding queue item. Hence we need to populate the media description accordingly to avoid the BT service to delay the update for two seconds and log an exception. [1] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/helpers/Metadata.java;l=120 [2] https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/android/app/src/com/android/bluetooth/audio_util/MediaPlayerWrapper.java;l=258 Issue: androidx/media#148 PiperOrigin-RevId: 491877806 (cherry picked from commit 2a07a0b44582782b09a96b5819e9899308e79545) * Rename SimpleBasePlayer.PlaylistItem to MediaItemData This better matches the terminology we use elsewhere in the Player interface, where items inside the playlist are referred to as "media item" and only the entire list is called "playlist". PiperOrigin-RevId: 491882849 (cherry picked from commit ff7fe222b83c55c93cc9ee1a3763a11473168ece) * Decomission ControllerInfoProxy in favor of ControllerInfo. This CL makes it possible to create a media3 ControllerInfo in test code, which is needed to test several aspects of a media3-based media app. It does this by exposing a test-only static factory method. This is a hacky low-effort approach; a better solution could be to split ControllerInfo up into a public interface that was exposed to client logic, and that they could extend, and a package-private implementation with internal fields like the callback. That's a much bigger change, however. PiperOrigin-RevId: 491978830 (cherry picked from commit 69093db7f5889037a3b55e3d1a7242c31ce62f2f) * Parse and set bitrates in `Ac3Reader` PiperOrigin-RevId: 492003800 (cherry picked from commit c7aa54cb411e485c2c17e630779d9e27d758a550) * Add media type to MediaMetadata This helps to denote what type of content or folder the metadata describes. PiperOrigin-RevId: 492123690 (cherry picked from commit 32fafefae81e0ab6d3769152e584981c1a62fc60) * Add support for most setters in SimpleBasePlayer This adds the forwarding logic for most setters in SimpleExoPlayer in the same style as the existing logic for setPlayWhenReady. This change doesn't implement the setters for modifying media items, seeking and releasing yet as they require additional handling that goes beyond the repeated implementation pattern in this change. PiperOrigin-RevId: 492124399 (cherry picked from commit f007238745850791f8521e61f6adaf8ed2467c45) * Merge pull request #10750 from Stronger197:subrip_utf_16 PiperOrigin-RevId: 492164739 (cherry picked from commit a9191418051a19681ddf884163ac5553871ec658) * Split SubripDecoder and ParsableByteArray tests In some cases we split a test method, and in other cases we just add line breaks to make the separation between arrange/act/assert more clear. PiperOrigin-RevId: 492182769 (cherry picked from commit e4fb663b23e38eb6e41b742681bf80b872baad24) * Reduce log output for failing bitmap loads Do not log the exception stack traces raised by the BitmapLoader when a bitmap fails to load, e.g. when the artwork's URI scheme is not supported by the SimpleBitmapLoader. The logs are kept in place but only a single line is printed. #minor-release PiperOrigin-RevId: 492191461 (cherry picked from commit f768ff970ca15483bcb02c1cf41746b67ec8c3ac) * Stop service when app is terminated while the player is paused If the service ever has been started but is not in the foreground, the service would be terminated without calling onDestroy(). This is because when onStartCommand returns START_STICKY [1], the app takes the responsibility to stop the service. Note that this change interrupts the user journey when paused, because the notification is removed. Apps can implement playback resumption [2] to give the user an option to resume playback after the service has been terminated. [1] https://developer.android.com/reference/android/app/Service#START_STICKY [2] https://developer.android.com/guide/topics/media/media-controls#supporting_playback_resumption Issue: androidx/media#175 #minor-release PiperOrigin-RevId: 492192690 (cherry picked from commit 6a5ac19140253e7e78ea65745914b0746e527058) * Write media type with a custom key to legacy components. This allows legacy media controllers and browsers to access this information and legacy sessions and browser services to set this information. PiperOrigin-RevId: 492414716 (cherry picked from commit ca4c6efdb7fdb50cef116d26360b79ed75a6401e) * Added cancellation check for MediaBrowserFuture in demo session app When app is deployed with device's screen being off, MainActivity's onStart is called swiftly by its onStop. The onStop method cancels the browserFuture task which in turn "completes" the task. Upon task "completion", pushRoot() runs and then throws error as it calls get() a cancelled task. PiperOrigin-RevId: 492416445 (cherry picked from commit 64603cba8db9fbd9615e19701464c4d0734a86dc) * Removed ExoPlayer specific states from SimpleBasePlayer PiperOrigin-RevId: 492443147 (cherry picked from commit 2fd38e3912960c38d75bce32cc275c985a2722c1) * Fix `TextRenderer` exception when a subtitle file contains no cues Discovered while investigating Issue: google/ExoPlayer#10823 Example stack trace with the previous code (I added the index value for debugging): ``` playerFailed [eventTime=44.07, mediaPos=44.01, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:635) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:202) at android.os.Looper.loop(Looper.java:291) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.IllegalArgumentException: index=-1 at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55) at androidx.media3.extractor.text.webvtt.WebvttSubtitle.getEventTime(WebvttSubtitle.java:62) at androidx.media3.extractor.text.SubtitleOutputBuffer.getEventTime(SubtitleOutputBuffer.java:56) at androidx.media3.exoplayer.text.TextRenderer.getCurrentEventTimeUs(TextRenderer.java:435) at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:268) at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1008) at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:202) at android.os.Looper.loop(Looper.java:291) at android.os.HandlerThread.run(HandlerThread.java:67) ] ``` #minor-release PiperOrigin-RevId: 492464180 (cherry picked from commit 33bbb9511a9ac6ad6495d4e264f8e248c4342763) * Fix `ExoPlayerTest` to use `C.TIME_UNSET` instead of `C.POSITION_UNSET` This inconsistency was exposed by an upcoming change to deprecate `POSITION_UNSET` in favour of `INDEX_UNSET` because position is an ambiguous term between 'byte offset' and 'media position', as shown here. PiperOrigin-RevId: 492470241 (cherry picked from commit 2650654dd0d0654fc4cca67b0d3347d88431fa4e) * Fix threading of onFallbackApplied callback The callback is currently triggered on the ExoPlayer playback thread instead of the app thread that added the listener. PiperOrigin-RevId: 492474405 (cherry picked from commit 634c6161f11f33b960023350d418bd3493f5a4b9) * Add javadoc links to README files Fix some other link titles and destinations spotted along the way. #minor-release PiperOrigin-RevId: 493276172 (cherry picked from commit 636a4a8538ccfb235eeca7d9131d4b5d4d95e9aa) * Support release in SimpleBasePlayer This adds support for the release handling. To align with the established behavior in ExoPlayer, the player can only call listeners from within the release methods (and not afterwards) and automatically enforces an IDLE state (without listener call) in case getters of the player are used after release. PiperOrigin-RevId: 493543958 (cherry picked from commit 4895bc42ff656ba77b604d8c7c93cba64733cc7a) * Replace MediaMetadata folderType by isBrowsable The folder type has a mix of information about the item. It shows whether the item is browsable (type != FOLDER_TYPE_NONE) and which Bluetooth folder type to set for legacy session information. It's a lot clearer to split this into a boolean isBrowsable and use the existing mediaType to map back to the bluetooth folder type where required. folderType is not marked as deprecated yet as this would be an API change, which will be done later. PiperOrigin-RevId: 493544589 (cherry picked from commit ae8000aecaee725dea51a6ded06125884a5b8112) * Remove debug timeout multiplier. It looks like this was added accidentally in <unknown commit>. PiperOrigin-RevId: 493834134 (cherry picked from commit 533f5288f4aec47a75357bf308907d1686ba493a) * Clarify and correct allowed multi-threading for some Player methods Some Player methods like getting the Looper and adding listeners were always allowed to be called from any thread, but this is undocumented. This change makes the threading rules of these methods more explicit. Removing listeners was never meant to be called from another thread and we also don't support it safely because final callbacks may be triggered from the wrong thread. To find potential issues, we can assert the correct thread when releasing listeners. Finally, there is a potential race condition when calling addListener from a different thread at the same time as release, which may lead to a registered listener that could receive callbacks after the player is released. PiperOrigin-RevId: 493843981 (cherry picked from commit 927b2d6a435a236bb5db7646cf6402557db893f6) * Forward seek command details to seekTo method in BasePlayer BasePlayer simplifies implementations by handling all the various seek methods and forwarding to a single method that can then be implemented by subclasses. However, this loses the information about the concrete entry point used for seeking, which is relevant when the subclass wants to verify or filter by Player.Command. This can be improved by adding the command as a new parameter. Since we have to change the method anyway, we can also incorporate the boolean flag about whether the current item is repeated to avoid the separate method. PiperOrigin-RevId: 494948094 (cherry picked from commit ab6fc6a08d0908afe59e7cd17fcaefa96acf1816) * Reset isLoading when calling SimpleBasePlayer.stop/release isLoading is not allowed to be true when IDLE, so we have to set to false when stopping in case it was set to true before. PiperOrigin-RevId: 494975405 (cherry picked from commit 6e7de583bb42871267899776966575512152b111) * Document the reason for defining private method `defaultIfNull` PiperOrigin-RevId: 495004732 (cherry picked from commit 610e431c906d71fd684c5c7c8ff8a9aa171a55ef) * Remove parameters with default values from bundle in `MediaItem` This improves the time taken to construct PlayerInfo from bundle from ~600ms to ~450ms. PiperOrigin-RevId: 495055355 (cherry picked from commit 395cf4debc52c9209377ea85a319d2e27c6533ce) * Fix some release notes typos PiperOrigin-RevId: 495262344 (cherry picked from commit c9e87f050303a78e39aa0c96eab48e30714f3351) * Clear one-off events from state as soon as they are triggered. This ensures they are not accidentally triggered again when the state is rebuilt with a buildUpon method. PiperOrigin-RevId: 495280711 (cherry picked from commit a1231348926b4a88a2a8cb059204c083e304f23f) * Allow unset index and position values + remove period index This simplifies some position tracking needs for an app implementing SimpleBasePlayer. - The period index can always be derived from the media item index and the position. So there is no need to set it separately. - The media item index can be left unset in the State in case the app doesn't care about the value or wants to set it the default start index (e.g. while the playlist is still empty where UNSET is different from zero). - Similarly, we should allow to set the content position (and buffered position) to C.TIME_UNSET to let the app ignore it or indicate the default position explictly. PiperOrigin-RevId: 495352633 (cherry picked from commit 545fa5946268908562370c29bd3e3e1598c28453) * Remove parameters with `null` values from bundle in `MediaMetadata` Improves the time taken to construct `playerInfo` from its bundle from ~450 ms to ~400 ms. Each `MediaItem` inside `Timeline.Window` contains `MediaMetadata` and hence is a good candidate for bundling optimisations. There already exists a test to check all parameters for null values when unset. PiperOrigin-RevId: 495614719 (cherry picked from commit d11e0a35c114225261a8fe472b0b93d4a8a6b727) * Use theme when loading drawables on API 21+ Issue: androidx/media#220 PiperOrigin-RevId: 495642588 (cherry picked from commit 22dfd4cb32fdb76ba10047f555c983490c27eb13) * Rename `EMPTY_MEDIA_ITEM` to `PLACEHOLDER_MEDIA_ITEM` The `MediaItem` instances in the following cases are not actually empty but acts as a placeholder. `EMPTY_MEDIA_ITEM` can also be confused with `MediaItem.EMPTY`. PiperOrigin-RevId: 495843012 (cherry picked from commit 3e7f53fda77048731d22de0221b0520a069eb582) * Clarify behavior for out-of-bounds indices and align implementations Some Player methods operate relative to existing indices in the playlist (add,remove,move,seek). As these operations may be issued from a place with a stale playlist (e.g. a controller that sends a command while the playlist is changing), we have to handle out- of-bounds indices gracefully. In most cases this is already documented and implemented correctly. However, some cases are not documented and the existing player implementations don't handle these cases consistently (or in some cases not even correctly). PiperOrigin-RevId: 495856295 (cherry picked from commit a1954f7e0a334492ffa35cf535d2e6c4e4c9ca91) * Check if codec still exists before handling tunneling events The tunneling callbacks are sent via Handler messages and may be handled after the codec/surface was changed or released. We already guard against the codec/surface change condition by creating a new listener and verifying that the current callback happens for the correct listener instance, but we don't guard against a released codec yet. PiperOrigin-RevId: 495882353 (cherry picked from commit 49ccfd63834d8ee68ac8018c42172da05108b35a) * Avoid sending periodic position updates while paused and not loading The period updates were introduced to ensure the buffered position is updated regularly and that any playback position drift is corrected. None of these updates need to happen while the player is paused or not loading and we can avoid the constant binder interactions. PiperOrigin-RevId: 496329800 (cherry picked from commit 0749b05923dd733bb515920334a9aae6067a072f) * Add playlist and seek operations to SimpleBasePlayer These are the remaining setter operations. They all share the same logic that handles playlist and/or position changes. The logic to create the placeholder state is mostly copied from ExoPlayerImpl's maskTimelineAndPosition and getPeriodPositonUsAfterTimelineChanged. PiperOrigin-RevId: 496364712 (cherry picked from commit 5fa115641d5b45b106844f3e629372417eb100b1) * Remove ellipsis from Player javadoc PiperOrigin-RevId: 496377192 (cherry picked from commit f0696f95720418d3c95a72f1454f712a40e40b8d) * Fix Dackka error due to param name mismatch https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter#seekTo(long) #minor-release PiperOrigin-RevId: 496378709 (cherry picked from commit aae6941981dfcfcdd46544f585335ff26d8f81e9) * Remove TODO from `ControllerInfo` - the existing approach is fine PiperOrigin-RevId: 496398934 (cherry picked from commit 14947539e53143e84f4453505a403fbe3625af5d) * Add BitmapLoader injection in MediaController Also clean up the strict mode violations of using `BitmapFactory.convertToByteArray` on the main thread. PiperOrigin-RevId: 496422355 (cherry picked from commit d848d3358a67ce2439db7cf170eec7b8c3ecffbf) * Clarify some Player command and method javadoc #minor-release PiperOrigin-RevId: 496661152 (cherry picked from commit 31e875b7a094963a9ef2a355ab1a4c6d7d3d9687) * Document the relationship between Player methods and available commands #minor-release PiperOrigin-RevId: 496668378 (cherry picked from commit d8c964cfe65bef4693056b052802ac1bee3ec56e) * Add error messages to correctness assertions in SimpleBasePlayer Users of this class may run into these assertions when creating the State and they need to check the source code to understand why the State is invalid. Adding error messages to all our correctness assertions helps to understand the root cause more easily. PiperOrigin-RevId: 496875109 (cherry picked from commit 6c98f238e45d19a14041d58f5938f3399da04eb5) * Fix recursive loop when registering controller visibility listeners There are two overloads of this method due to a type 'rename' from `PlayerControlView.VisibilityListener` to `PlayerView.ControllerVisibilityListener`. Currently when you call one overload it passes `null` to the other one (to clear the other listener). Unfortunately this results in it clearing itself, because it receives a null call back! This change tweaks the documentation to clarify that the 'other' listener is only cleared if you pass a non-null listener in. This solves the recursive problem, and allows the 'legacy' visibility listener to be successfully registered. Issue: androidx/media#229 #minor-release PiperOrigin-RevId: 496876397 (cherry picked from commit 4087a011e21aba2c27e3ae890f74a65812c6f4ce) * Update migration script Issue: google/ExoPlayer#10854 PiperOrigin-RevId: 496922055 (cherry picked from commit 50090e39273356bee9b8da6b2f4a4dba1206f9a8) * Bump IMA SDK version to 3.29.0 Issue: google/ExoPlayer#10845 PiperOrigin-RevId: 496947392 (cherry picked from commit 63352e97e99cc6ab2e063906be63392ea8b984b3) * Check `MediaMetadata` bundle to verify keys are skipped Added another check in test to make sure we don't add keys to bundle for fields with `null` values. PiperOrigin-RevId: 496948705 (cherry picked from commit 13c93a3dd693e86e6d5208aff45105000858363f) * Optimise bundling for `AdPlaybackState` using `AdPlaybackState.NONE` Did not do this optimisation for `AdPlaybackState.AdGroup` as its length is zero for `AdPlaybackState` with no ads. No need to pass default values while fetching keys, which we always set in `AdPlaybackState.AdGroup.toBundle()`. PiperOrigin-RevId: 496995048 (cherry picked from commit 7fc2cdbe1bdf9968a1e73a670e5e32454090e1bd) * Fix order of playback controls in RTL layout Issue: androidx/media#227 #minor-release PiperOrigin-RevId: 497159283 (cherry picked from commit 80603427abbd0da09f21e381cc10a5d47fb6d780) * Enable RTL support in the demo app We might as well keep this enabled by default, rather than having to manually toggle it on to investigate RTL issues like Issue: androidx/media#227. PiperOrigin-RevId: 497159744 (cherry picked from commit 69583d0ac1fa1ab1a1e250774fc1414550625967) * Remove player listener on the application thread of the player PiperOrigin-RevId: 497183220 (cherry picked from commit fc22f89fdea4aad4819a59d4819f0857a5596869) * Check bundles in `MediaItem` to verify keys are skipped Added another check in each of these tests to make sure we don't add keys to bundle for fields with default values. Also fixed comments of similar changes in `AdPlaybackStateTest` and `MediaMetadataTest`. PiperOrigin-RevId: 499463581 (cherry picked from commit 0512164fdd570a2047f51be719aae75ebcbf9255) * Optimise bundling for `Timeline.Window` and `Timeline.Period` Improves the time taken to construct playerInfo from its bundle from ~400 ms to ~300 ms. Also made `Timeline.Window.toBundle(boolean excludeMediaItem)` public as it was required to assert a condition in tests. PiperOrigin-RevId: 499512353 (cherry picked from commit 790e27d929906a36438af5b42ef62a13e4719045) * Throw a ParserException instead of a NullPointerException if the sample table (stbl) is missing a required sample description (stsd). As per the javadoc for AtomParsers.parseTrack, ParserException should be "thrown if the trak atom can't be parsed." PiperOrigin-RevId: 499522748 (cherry picked from commit d8ea770e9ba6eed0bdce0b359c54a55be0844fd3) * Fix typo in `DefaultTrackSelector.Parameters` field PiperOrigin-RevId: 499905136 (cherry picked from commit b63e1da861d662f02d9a5888aaefb4a1b3347e40) * Initialise fields used for bundling as String directly Initialising the fields as Integer and then getting a String on compute time is slow. Instead we directly initialise these fields as String. Improves the time taken in bundling PlayerInfo further to less than 200ms from ~300ms. Also modified a test to improve productive coverage. PiperOrigin-RevId: 500003935 (cherry picked from commit 578f2de48f795ad90aafdad645c62fcdbd686e0a) * Update bandwidth meter estimates PiperOrigin-RevId: 501010994 (cherry picked from commit 2c7e9ca8237e39bde686dd635699778aa8c6b96e) * Add focusSkipButtonWhenAvailable to focus UI on ATV For TV devices the skip button needs to have the focus to be accessible with the remote control. This property makes this configurable while being set to true by default. PiperOrigin-RevId: 501077608 (cherry picked from commit 9882a207836bdc089796bde7238f5357b0c23e76) * Use onMediaMetadataChanged for updating the legacy session Issue: androidx/media#219 PiperOrigin-RevId: 501080612 (cherry picked from commit 375299bf364041ccef17b81020a13af7db997433) * Improve Java doc about how to override notification drawables Issue: androidx/media#140 PiperOrigin-RevId: 501288267 (cherry picked from commit a2cf2221170e333d1d1883e0e86c5efca32f55ba) * Request notification permission in demo app for API 33+ Starting with API 33 the POST_NOTIFICATION permission needs to be requested at runtime or the notification is not shown. Note that with an app with targetSdkVersion < 33 but on a device with API 33 the notification permission is automatically requested when the app starts for the first time. If the user does not grant the permission, requesting the permission at runtime result in an empty array of grant results. Issue: google/ExoPlayer#10884 PiperOrigin-RevId: 501320632 (cherry picked from commit 6484c14acd4197d335cab0b5f2ab9d3eba8c2b39) * Document that `DownloadService` needs notification permissions Starting with Android 13 (API 33) an app needs to request the permission to post notifications or notifications are suppressed. This change documents this in the class level JavaDoc of the `DownloadService`. Issue: google/ExoPlayer#10884 PiperOrigin-RevId: 501346908 (cherry picked from commit 20aa5bd9263f594e4f1f8029c5b80e9f204bff3a) * Add AdsLoader.focusSkipButton() This method allows to call through to `StreamManager.focus()` of the currently playing SSAI stream. PiperOrigin-RevId: 501399144 (cherry picked from commit 16285ca5dfd4461334f5e97d4de47ae07e49e883) * Catch FgSStartNotAllowedException when playback resumes This fix applies to Android 12 and above. In this fix, the `MediaSessionService` will try to start in the foreground before the session playback resumes, if ForegroundServiceStartNotAllowedException is thrown, then the app can handle the exception with their customized implementation of MediaSessionService.Listener.onForegroundServiceStartNotAllowedException. If no exception thrown, the a media notification corresponding to paused state will be sent as the consequence of successfully starting in the foreground. And when the player actually resumes, another media notification corresponding to playing state will be sent. PiperOrigin-RevId: 501803930 (cherry picked from commit 0d0cd786264aa82bf9301d4bcde6e5c78e332340) * Correctly map deprecated methods in MediaController to replacement This avoids throwing exceptions for correct (but deprecated) Player method invocations. PiperOrigin-RevId: 502341428 (cherry picked from commit 86a95c2a4afd861986376f9dc31e0d65910e6e74) * Remove unneccesary parameter taking Player.Command The method to dispatch actions in MediaControllerImplBase takes a Player.Command, but the value is only used to check if we are setting a surface and need to handle the special blocking call. This can be cleaned up by removing the parameter and calling a dedicated blocking method where needed. This also ensures we have to mention the relevant Player.Command only once in each method. PiperOrigin-RevId: 502341862 (cherry picked from commit 664ab72d090196625b5f533e9f0a2112951c5741) * Add missing command checks to MediaSessionLegacyStub and PlayerWrapper This player didn't fully check all player commands before calling the respective methods. PiperOrigin-RevId: 502353704 (cherry picked from commit a2a44cdc02abadd473e26e1fd9f973210d4c5f0e) * Fix command check in MediaControllerImplBase The command check for setDeviceMuted was wrong. PiperOrigin-RevId: 502355332 (cherry picked from commit cfcce9aec9d92a7067f07b2d9c00d705df0368ac) * Clarify what default settings are being used for SSAI AdsLoader PiperOrigin-RevId: 502388865 (cherry picked from commit abe11c88ecdfe56ca31d3bffe1dd8fce6fb293af) * Post notification for session app when FgS starting exception is caught PiperOrigin-RevId: 502407886 (cherry picked from commit 6ce3421ca750109acfea35029260dc3f169a1a40) * Filter what PlaybackStateCompat actions are advertised PlayerWrapper advertises PlaybackStateCompat actions to the legacy MediaSession based on the player's available commands. PiperOrigin-RevId: 502559162 (cherry picked from commit 39f4a17ad4ac3863af22e12711247c7a87b8613e) * Disables play/pause button when there's nothing to play PiperOrigin-RevId: 502571320 (cherry picked from commit d49a16e094d6d4bde0d1dc1ec42876c156b9c55a) * Make availableCommands known when bundling PlayerInfo When bundling PlayerInfo, we remove data when the controller is not allowed to access this data via getters. We also remove data for performance reasons. In the toBundle() method, it's currently hard to make the connection between allowed commands and filtering, because the values are checked at a different place. This can be made more readable by forwarding the applicable Commands directly. The only functional fix is to filter the Timeline when sending the first PlayerInfo after a connecting a controller if the command to get the Timeline is not available. This also allows us to remove a path to filter MediaItems from Timelines as it isn't used. PiperOrigin-RevId: 502607391 (cherry picked from commit c90ca7ba5fb9e83956e9494a584ae6b0620e3b14) * Fix javadoc references to `writeSampleData` PiperOrigin-RevId: 502821506 (cherry picked from commit 6c14ffc1ecd13393930b9f5ee7ad7a52391d0f65) * Correctly filter PlayerInfo by available getter commands. When bundling PlayerInfo, we need to remove information if the controller is not allowed to access it. This was only partially done at the moment. PiperOrigin-RevId: 502852798 (cherry picked from commit 69cfba7c53b563577390e4074fd270f078bf6069) * Extend command GET_CURRENT_MEDIA_ITEM to more methods. We currently only document it for the getCurrentMediaItem(), but the command was always meant to cover all information about the current media item and the position therein. To correctly hide information for controllers, we need to filter the Timeline when bundling the PlayerInfo class if only this command is available. PiperOrigin-RevId: 503098124 (cherry picked from commit f15b7525436b45694b5e1971dac922adff48b5ae) * Update media controller position before pausing. We stop estimating new position when pausing until we receive a new position from the player. However, this means that we will continue to return a possible stale previous position. Updating the current position before pausing solves this issue. PiperOrigin-RevId: 503153982 (cherry picked from commit e961c1b5e9bb4a6f63458b1bdcb49e97f415fabf) * Add command check for metadata in DefaultMediaNotificationProvider PiperOrigin-RevId: 503172986 (cherry picked from commit 052c4b3c1a6b72efd7fcbf433c646fed9ea91748) * Explicitly document most Player.Listener methods in terms of getters This makes it implicitly clear that if the value of a getter changes due to a change in command availability then the listener will be invoked, without needing to explicitly document every command on every listener method. #minor-release PiperOrigin-RevId: 503178383 (cherry picked from commit 280889bc4a5b7ddc1b1c9fe15e222cad7f2e548a) * Add the MediaSession as an argument to `getMediaButtons()` Issue: androidx/media#216 #minor-release PiperOrigin-RevId: 503406474 (cherry picked from commit e690802e9ecf96dfbb972864819a45ae92c47c90) * Add onSetMediaItems listener with access to start index and position Added onSetMediaItems callback listener to allow the session to modify/set MediaItem list, starting index and position before call to Player.setMediaItem(s). Added conditional check in MediaSessionStub.setMediaItem methods to only call player.setMediaItem rather than setMediaItems if player does not support COMMAND_CHANGE_MEDIA_ITEMS PiperOrigin-RevId: 503427927 (cherry picked from commit bb11e0286eaa49b4178dfa29ebaea5dafba8fc39) * Add missing # in release notes PiperOrigin-RevId: 504013985 (cherry picked from commit 5147011772286778e84410012a24e329fde12040) * Deduplicate onSetMediaItem handler logic Created unified MediaUtils method to handle various logic for calling Player.setMediaItems from MediaSessionStub and MediaSessionLegacyStub PiperOrigin-RevId: 504271877 (cherry picked from commit 7fbdbeb6cafe075f04b6a4321ef826643b3482e1) * Suppress warnings in ImaUtil ImaUtil calls VideoProgressUpdate.equals() which is annotated as hidden, which causes lint errors with gradle. #minor-release PiperOrigin-RevId: 504306210 (cherry picked from commit 5f6e172c8fce652adf2c05e8f2d041c793e900ea) * Filter available commands based on PlaybackStateCompat actions This allows a MediaController to understand which methods calls are available on a legacy session. PiperOrigin-RevId: 504306806 (cherry picked from commit 067340cb0a03dede0f51425de00643fe3789baf2) * Publish gradle attributes for AndroidX compatibility These attributes are required when importing our artifacts into androidx-main in order to generate reference documentation (JavaDoc and KDoc). #minor-release PiperOrigin-RevId: 504502555 (cherry picked from commit 47349b8c4bd69415da8895061be71ef748c4a2d3) * Add missing } to publish.gradle This was missed in https://github.com/androidx/media/commit/47349b8c4bd69415da8895061be71ef748c4a2d3 #minor-release PiperOrigin-RevId: 504548659 (cherry picked from commit 50beec56f4188e46f67e561ac4bb4ace5bb95089) * Add missing command checks in UI module The commands are partly checked already before enabling features or calling player methods, but the checks were still missing in many places. #minor-release PiperOrigin-RevId: 504589888 (cherry picked from commit e2ece2f5bcda0cea436d782d58fa6f1d9a4d1f99) * Tweak UI behavior when commands are missing. For most missing commands, we already disable the corresponding controls. This change extends this to more UI elements that are disabled in case the corresponding action is unavailable. #minor-release PiperOrigin-RevId: 505057751 (cherry picked from commit b3e7696ba7d66a2d3c477858194a20789f4d75c7) * Match MergingMediaPeriod track selection by period index in id MergingMediaPeriod creates its track groups with ids concatenating position in its periods array and the underlying child track group id. The ids can be used in selectTracks for matching to periods list. Issue: google/ExoPlayer#10930 PiperOrigin-RevId: 505074653 (cherry picked from commit 542a1ef03f361b29ec731a7334b2922cb54ef4c9) * Double tap detection for Bluetooth media button events only Issue: androidx/media#233 #minor-release PiperOrigin-RevId: 505078751 (cherry picked from commit 5c82d6bc18429842160bb64a851bb1ab5c89ec39) * Fix timestamp comparison for seeks in fMP4 When seeking in fMP4, we try to extract as little samples as possible by only starting at the preceding sync frame. This comparison should use <= to allow sync frames at exactly the seek position. Issue: google/ExoPlayer#10941 PiperOrigin-RevId: 505098172 (cherry picked from commit 00436a04a4f0fec8ee9154fc1568ca4013ca5c7d) * Inline method in PlayerService that is used from on call site only #cleanup #minor-release PiperOrigin-RevId: 505146915 (cherry picked from commit d7ef1ab5bd5a4508c0913011f5990bb03a57585a) * Do not assume a valid queue in 3rd party sessions This change fixes an issue that can be reproduced when a controller `onConnect` creates a `QueueTimeline` out of the state of a legacy session and then `prepare` is called. `activeQueueItemId`, `metadata` and the `queue` of the legacy session are used when a `QueueTimeline` is created. The change adds unit tests to cover the different combinatoric cases these properties being set or unset. PiperOrigin-RevId: 505731288 (cherry picked from commit 4a9cf7d069b1b35be807886d59d87c396b19876c) * Fix (another) `LeanbackPlayerAdapter` param name mismatch I missed this when fixing `positionInMs` for Dackka in https://github.com/androidx/media/commit/aae6941981dfcfcdd46544f585335ff26d8f81e9 This time I manually verified that all the `@Override` methods have parameter names that match [the docs](https://developer.android.com/reference/androidx/leanback/media/PlayerAdapter). #minor-release PiperOrigin-RevId: 506017063 (cherry picked from commit d1a27bf2a81709bc7b03ad130bc9abd4d8b27164) * Merge pull request #10793 from fraunhoferfokus:dash-thumbnail-support PiperOrigin-RevId: 506261584 (cherry picked from commit c6569a36fbce6fc3ece55c9a904508bd4a4c45da) * Publish ConcatenatingMediaSource2 Can be used to combine multiple media items into a single timeline window. Issue: androidx/media#247 Issue: google/ExoPlayer#4868 PiperOrigin-RevId: 506283307 (cherry picked from commit fcd3af6431cfcd79a3ee3cc4fee38e8db3c0554e) * Session: advertise legacy FLAG_HANDLES_QUEUE_COMMANDS This change includes 3 things: - when the legacy media session is created, FLAG_HANDLES_QUEUE_COMMANDS is advertised if the player has the COMMAND_CHANGE_MEDIA_ITEMS available. - when the player changes its available commands, a new PlaybackStateCompat is sent to the remote media controller to advertise the updated PlyabackStateCompat actions. - when the player changes its available commands, the legacy media session flags are sent accoridingly: FLAG_HANDLES_QUEUE_COMMANDS is set only if the COMMAND_CHANGE_MEDIA_ITEMS is available. #minor-release PiperOrigin-RevId: 506605905 (cherry picked from commit ebe7ece1eb7e2106bc9fff02db2666410d3e0aa8) * Fix release note entry * Prepare media3 release notes for rc01 PiperOrigin-RevId: 509218510 (cherry picked from commit 73909222706c6d7a56e0fb2d09ed8b49eca5b2be) * Minor fixes in release notes PiperOrigin-RevId: 509222489 (cherry picked from commit a90728fdc66cc2a8929cce9d67081681e0168115) * Version bump for ExoPlayer 2.18.3 & media3-1.0.0-rc01 #minor-release PiperOrigin-RevId: 509501665 (cherry picked from commit 20eae0e041e1922fd79ca36218054b293a9da7da) * Detect HEVC HDR10 codec profile more accurately In MediaCodecUtil, use Format.colorInfo, besides the codec string, to accurately map to a 10bit HEVC profile. PiperOrigin-RevId: 507500071 (cherry picked from commit a50ea94525d2522436fbc812dec12aee53b3c1bf) * Fix AudioTrackPositionTracker logic for playback speed adjustments The AudioTrackPositionTracker needs to correct positions by the speed set on the AudioTrack itself whenever it makes estimations based on real-time (=the real-time playout duration is not equal to the media duration played). This happens for the main playback path already, but not for the mode in which the position is estimated from the playback head position and also not in the phase after the track has been stopped. Both cases are not very noticeable during normal playback, but become relevant when playing in offload mode. PiperOrigin-RevId: 507736408 (cherry picked from commit 01d7bc72794b98d19cad2be5c70de2f755bff9f1) * Merge pull request #248 from lemondoglol:update-segment-size PiperOrigin-RevId: 507784608 (cherry picked from commit ecd91d865c0888c6cc1aa3554877f4df798f5379) * Merge pull request #10959 from balachandarlinks:handle-sql-exception-in-cached-content-index PiperOrigin-RevId: 508323432 (cherry picked from commit 1249dcdc47a4c3b4dbd642c3991945b23de8112b) * Document spatialization behavior constants. PiperOrigin-RevId: 508602059 (cherry picked from commit 6066ce43f66317f708e6e0076580e1bc1182186d) * Add null check to `ExoPlayerImpl.isTunnelingEnabled` `TrackSelectorResult.rendererConfigurations` can contain null elements: > A null entry indicates the corresponding renderer should be disabled. This wasn't caught by the nullness checker because `ExoPlayerImpl` is currently excluded from analysis. #minor-release Issue: google/ExoPlayer#10977 PiperOrigin-RevId: 508619169 (cherry picked from commit a6dfcf779942cb76c495fb5f7bc5444da6147b9d) * AsynchronousMediaCodecAdapter: surface queueing errors sooner The AsynchronousMediaCodecAdapter's queuing thread stores any exceptions raised by MediaCodec and re-throws them on the next call to queueInputBuffer()/queueSecureInputBuffer(). However, if MediaCodec raises and error while queueing, it goes into a failed state and does not announce available input buffers. If there is no input available input buffer, the MediaCodecRenderer will never call queueInputBuffer()/queueSecureInputBuffer(), hence playback is stalled. This change surfaces the queueing error through the adapter's dequeueing methods. PiperOrigin-RevId: 508637346 (cherry picked from commit 706431059cadf1b503ea8f95fd482d41f48e1a1c) * Add ad event listeners in the Looper event of the ad manager callback #minor-release PiperOrigin-RevId: 509189206 (cherry picked from commit 51929625cfeff17af413c1a06c87e10e72f218d1) * Catch IllegalArgumentExceptions in RTSP Response parsing In parsing Describe RTSP response messages, IllegalArgumentExceptions are thrown for invalid parameters and values. These exceptions were not caught and crashed the Playback thread. Now these exceptions will be caught and their errors forwarded to the proper error handling listeners. Issue: google/ExoPlayer#10971 PiperOrigin-RevId: 509207881 (cherry picked from commit a8c87453db02658a21293b44b017a70d5ae1125d) * Add exception cause to thrown exception PiperOrigin-RevId: 509473556 (cherry picked from commit 56803bf1ad3e4df2ebd8d7b38f5a9f4740dc702f) * Fix error in documentation string The current javadoc refers to the SessionCallback#onConnected, which doesn't exist. PiperOrigin-RevId: 510261965 (cherry picked from commit fc642eb45f6c997a2a501bcc3ea19043cd9911eb) * Map `PLAYER_STATE_LOADING` to `STATE_BUFFERING` #minor-release Issue: androidx/media#245 PiperOrigin-RevId: 510456793 (cherry picked from commit ba49b6b81b9a6a01aa16381cca70886bc205c5c5) * Reduce number of calls to AudioTrack.getPlaybackHeadPosition This call may cause performance overhead in some situations, for example if the AudioTrack needs to query an offload DSP for the current position. We don't need to check this multiple times per doSomeWork iteration as the value is unlikely to change in any meaningful way. PiperOrigin-RevId: 510957116 (cherry picked from commit 9eccf09165f39d89d502065f897d120b97f47f66) * Skip rendering multiple frames on the same vsync When rendering frames at a rate higher than the screen refresh rate, e.g. playing at 8x, the player is releasing multiple frames at the same release time (nanos) which are then dropped by the platform. The output buffers are available later and as a result MediaCodec cannot keep up decoding fast enough. This change skips releasing multiple video frames on the same vsync period and proactivelly drops the frame. The frame is counted as skipped rather than dropped to differentiate with frames dropped due to slow decoding. PiperOrigin-RevId: 510964976 (cherry picked from commit ab7e84fb34b7ef4b13e492e1f8918345c712ec30) * Use ArrayDeque for pending output stream changes. The current logic uses manual array operations to keep track of pending changes. Modernize this code by using an ArrayDeque and a data class. This also allows to extend the output stream information in the future. This also fixes a bug where a position reset accidentally assigns a pending stream offset instead of keeping the current one. PiperOrigin-RevId: 511787571 (cherry picked from commit f0420124954527e7f3eb529ca24f2a51dc7319f9) * Do not specify export flags for protected system broadcasts. Protected system broadcasts should not specify the export flag. Marking them as NOT_EXPORTED breaks sticky broadcasts in some cases. Issue: google/ExoPlayer#10970 PiperOrigin-RevId: 512020154 (cherry picked from commit 93e117928c157ef338faa46dea25ee114f18d3eb) * Use more realistic time values for MediaCodecVideoRendererTest This test became flaky after https://github.com/androidx/media/commit/ab7e84fb34b7ef4b13e492e1f8918345c712ec30 because some of the unrealistic frame times ended up on the same release time. Using realistic numbers avoids the flakiness. PiperOrigin-RevId: 512566469 (cherry picked from commit 0c8ce183fe7e2f065ca4dea33818566e9aeff48f) * Correctly update output info if previous stream has been fully rendered The output info for a new stream is marked pending until the last sample of the previous stream has been processed. However, this fails if the previous stream has already been fully processed. We need to detect this case explicitly to avoid signalling the output change one sample too late. #minor-release PiperOrigin-RevId: 512572854 (cherry picked from commit 7ffcc6f7ea648fb89b487f4c381b1d886cc8a638) * Add workaround for wrong PerformancePoints on some devices. Some devices were reported to have wrong PerformancePoint sets that cause 60 fps to be marked as unsupported even though they are supported. Issue: google/ExoPlayer#10898 PiperOrigin-RevId: 512580395 (cherry picked from commit d0cbf0fce84aa73be5eb68935d6a4dd2f2e1dc3d) * Ensure output format is updated in sync with stream changes. MediaCodecRenderer currently has two independent paths to trigger events at stream changes: 1. Detection of the last output buffer of the old stream to trigger onProcessedStreamChange and setting the new output stream offset. 2. Detection of the first input buffer of the new stream to trigger onOutputFormatChanged. Both events are identical for most media. However, there are two problematic cases: A. (1) happens after (2). This may happen if the declared media duration is shorter than the actual last sample timestamp. B. (2) is too late and there are output samples between (1) and (2). This can happen if the new media outputs samples with a timestamp less than the first input timestamp. This can be made more robust by: - Keeping a separate formatQueue for each stream to avoid case A. - Force outputting the first format after a stream change to avoid case B. Issue: google/ExoPlayer#8594 PiperOrigin-RevId: 512586838 (cherry picked from commit 3970343846d7bae5d8ae331d74241c50777ce18a) * Update notification play/pause button with matching player state Issue: androidx/media#192 PiperOrigin-RevId: 508649684 (cherry picked from commit e1d12fc395d9f9edb28755a5b1026e26b378e005) * Fix some playback parameter signalling problems. Playback parameter signalling can be quite complex because (a) the renderer clock often has a delay before it realizes that it doesn't support a previously set speed and (b) the speed set on media clock sometimes intentionally differs from the one surfaced to the user, e.g. during live speed adjustment or when overriding ad playback speed to 1.0f. This change fixes two problems related to this signalling: 1. When resetting the media clock speed at a period transition, we don't currently tell the renderers that this happened. 2. When a delayed speed change update from the media clock is pending and the renderer for this media clock is disabled before the change can be handled, the pending update becomes stale but it still applied later and overrides any other valid speed set in the meantime. Both edge cases are also covered by extended or new player tests. Issue: google/ExoPlayer#10882 PiperOrigin-RevId: 512658918 (cherry picked from commit e79b47ccff39363543c514937aef517a855994f0) * Ensure getPlaybackHeadPosition isn't called if not needed Once the value returned from AudioTimestampPoller advances, we only need getPlaybackHeadPosition to sample sync params and verify the returned timestamp. Both of these happen less often and we can avoid calling getPlaybackHeadPosition if we don't actually need it. PiperOrigin-RevId: 512882170 (cherry picked from commit 408b4449ff75e29a9bda7adc1b530b993fc47814) * Update translations #minor-release PiperOrigin-RevId: 512890813 (cherry picked from commit a7faa5bfd8c82e22c7d99378cf78f31a57274db2) * Minor change in ForwardingPlayer javadoc #minor-release PiperOrigin-RevId: 512897269 (cherry picked from commit 42fae152d0ad381c8bbb0858f596770529f11f40) * Remove @see tags with <a> tags These are not supported by Dackka #minor-release PiperOrigin-RevId: 513176533 (cherry picked from commit c07cf3dc414b562652cdd4f3b0e91f80493a2c40) * Merge pull request #255 from mayurk2:use_edts_offset_if_it_is_for_entire_file PiperOrigin-RevId: 513213229 (cherry picked from commit 17499cefcc1b27d90ecdf136bd3b2e4856ddcaf1) * Update release notes for 1.0.0-rc02 PiperOrigin-RevId: 513483809 (cherry picked from commit df11545ba18f9bf3e6e9c87c3bdb30bfb0723279) * Bump version numbers to Media3 1.0.0-rc02 and ExoPlayer 2.18.4 #minor-release PiperOrigin-RevId: 513488487 (cherry picked from commit cd753bd7b8c3206b509949e851f515ca465e4c89) * Fix some JavaDoc in the Media3 session module #minor-release PiperOrigin-RevId: 513501046 (cherry picked from commit 6042bec18a4b30449a20d1e858bac799cc6d18c3) * Remove unreleased changed * Fix lint-baseline.xml for latest UI translations #minor-release PiperOrigin-RevId: 513533248 (cherry picked from commit 8498e4b4445ae88665c6cdbc4e47e8e6ca7b7303) * Add missing RELEASENOTES line PiperOrigin-RevId: 513556883 (cherry picked from commit e2cb32f34ce016877fa7d2f4acc38511e7c261c0) * Shorten labels to fix transformer demo UI * Shorten labels to fix transformer demo UI * Add missing `@param` tags Dackka generates a warning if a method has at least one `@param` tag, but not all of them are documented. PiperOrigin-RevId: 513873453 (cherry picked from commit cb7d565fd47fc0b818ec0d5c7529e19df44022b5) * Update templates to more clearly signpost between exoplayer2 and media3 Issue: google/ExoPlayer#11031 #minor-release PiperOrigin-RevId: 514366016 (cherry picked from commit 9c82923094400e0b840a983e55be26b1dd76e7d2) *…
In Media3 there is no class/mechanism equivalent of a
MediaSessionManager
?If I want my app to control the media session that another app is running, the only way is to convert
android.media.session.MediaSession.Token
(obtained by the systemMediaSessionManager
) toMediaSessionCompat.Token
then to convert it again toandroidx.media3.session.Token
? Or did I miss something?The text was updated successfully, but these errors were encountered: