Skip to content
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

1.0.0 rc01 #251

Merged
merged 141 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
537f8b2
Changed decoder list sort to order by functional support of format
microkatz Nov 11, 2022
bbf7324
Update targetSdkVersion of demo session app to appTargetSdkVersion
tianyif Nov 16, 2022
73d40e1
Add bundling exclusions with unit tests
marcbaechinger Nov 16, 2022
c11b5cf
Fix NPE when listener is not set
a-googler Nov 16, 2022
9ba059f
Add setPlaybackLooper ExoPlayer builder method
a-googler Nov 16, 2022
f3268ac
Load bitmaps for `MediaBrowserCompat`.
tianyif Nov 17, 2022
91c51fe
Mark broadcast receivers as not exported
tonihei Nov 17, 2022
9ac5062
Throw exception if a released player is passed to TestPlayerRunHelper
icbaker Nov 17, 2022
68a1571
Add additional codecs to the eosPropagationWorkaround list.
tonihei Nov 17, 2022
0e628fb
Pass correct frame size for passthrough playback
christosts Nov 17, 2022
9e42426
Add remaining state and getters to SimpleBasePlayer
tonihei Nov 18, 2022
f4f801a
Do not require package visibility when connecting to a Media3 session
tonihei Nov 21, 2022
3476ca9
Add `set -eu` to all shell scripts
icbaker Nov 21, 2022
fa6b8fe
Do not require package visibility when obtaining SessionTokens
tonihei Nov 22, 2022
dddb72b
Add `DefaultExtractorsFactory.setTsSubtitleFormats`
icbaker Nov 22, 2022
5a96fc7
Reorder some release notes in other sections.
tonihei Nov 22, 2022
d3d99f0
Load bitmaps for `MediaSessionCompat.QueueItem`.
tianyif Nov 22, 2022
782a69e
Migrate BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS to Media3
marcbaechinger Nov 23, 2022
9829ff3
Add helper method to convert platform session token to Media3 token
tonihei Nov 23, 2022
a98efd8
Merge pull request #10786 from TiVo:p-aacutil-test-impl
icbaker Nov 24, 2022
0ba58cc
Call future listener on the same handler that created the controller
marcbaechinger Nov 23, 2022
8b0c076
Exclude tracks from `PlayerInfo` if not changed
marcbaechinger Nov 23, 2022
b495d21
Misc fix in gradle build file
christosts Nov 23, 2022
d58b4fd
Handle the bitmap loading result with applicationHandler
tianyif Nov 23, 2022
101a249
Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3
rohitjoins Nov 23, 2022
32f7a8b
Rollback of https://github.com/androidx/media/commit/76df06a7a364c580…
rohitjoins Nov 23, 2022
fda132f
Rollback of https://github.com/androidx/media/commit/427329175e87a7f3…
rohitjoins Nov 24, 2022
5ebbdc5
Use `ParsableBitArray` instead of `ParsableByteArray`
rohitjoins Nov 24, 2022
30dce91
Convert bitrates to bps before setting it
rohitjoins Nov 24, 2022
8767605
Remove flakiness from DefaultAnalyticsCollectorTest
tonihei Nov 25, 2022
d5815c5
Clean up javadoc on `Metadata.Entry.populateMediaMetadata`
icbaker Nov 25, 2022
f9c6fb4
Ensure messages sent on a dead thread don't block FakeClock execution
tonihei Nov 28, 2022
887179f
Merge pull request #10799 from OxygenCobalt:id3v2-multi-value
rohitjoins Nov 29, 2022
26f5e9b
Split up `Id3DecoderTest` methods
icbaker Nov 28, 2022
289f0cf
Remove impossible `UnsupportedEncodingException` from `Id3Decoder`
icbaker Nov 28, 2022
3bf9970
Merge pull request #10776 from dongvanhung:feature/add_support_clear_…
rohitjoins Nov 29, 2022
1d082ee
Bump cast sdk version and remove workaround for live duration
marcbaechinger Nov 29, 2022
e85e497
Add configuration to support OPUS offload
tonihei Nov 29, 2022
bb7e632
Use audio bitrate to calculate AudioTrack min buffer in passthrough
christosts Nov 29, 2022
4ecbd77
Add public constructors to `DefaultMediaNotificationProvider`
rohitjoins Nov 29, 2022
665f04d
Use the artist as the subtitle of the legacy media description
marcbaechinger Nov 30, 2022
05f640e
Rename SimpleBasePlayer.PlaylistItem to MediaItemData
tonihei Nov 30, 2022
93694b2
Decomission ControllerInfoProxy in favor of ControllerInfo.
a-googler Nov 30, 2022
8932c52
Parse and set bitrates in `Ac3Reader`
rohitjoins Nov 30, 2022
ed38ec7
Add media type to MediaMetadata
tonihei Dec 1, 2022
f8155f1
Add support for most setters in SimpleBasePlayer
tonihei Dec 1, 2022
6e58ca6
Merge pull request #10750 from Stronger197:subrip_utf_16
icbaker Dec 12, 2022
102873b
Split SubripDecoder and ParsableByteArray tests
icbaker Dec 1, 2022
1a9b1c4
Reduce log output for failing bitmap loads
christosts Dec 1, 2022
868e86c
Stop service when app is terminated while the player is paused
marcbaechinger Dec 1, 2022
8618263
Write media type with a custom key to legacy components.
tonihei Dec 2, 2022
c4f1c04
Added cancellation check for MediaBrowserFuture in demo session app
microkatz Dec 2, 2022
8844b4f
Removed ExoPlayer specific states from SimpleBasePlayer
microkatz Dec 2, 2022
5612f69
Fix `TextRenderer` exception when a subtitle file contains no cues
icbaker Dec 2, 2022
f43cc38
Fix `ExoPlayerTest` to use `C.TIME_UNSET` instead of `C.POSITION_UNSET`
icbaker Dec 2, 2022
515b6ac
Fix threading of onFallbackApplied callback
tonihei Dec 2, 2022
3df6949
Add javadoc links to README files
icbaker Dec 6, 2022
3b55ce2
Support release in SimpleBasePlayer
tonihei Dec 7, 2022
71a1254
Replace MediaMetadata folderType by isBrowsable
tonihei Dec 7, 2022
c32494a
Remove debug timeout multiplier.
tonihei Dec 8, 2022
80be30f
Clarify and correct allowed multi-threading for some Player methods
tonihei Dec 8, 2022
cdc07e2
Forward seek command details to seekTo method in BasePlayer
tonihei Dec 13, 2022
11bd727
Reset isLoading when calling SimpleBasePlayer.stop/release
tonihei Dec 13, 2022
1e7480d
Document the reason for defining private method `defaultIfNull`
rohitjoins Dec 13, 2022
d91c005
Remove parameters with default values from bundle in `MediaItem`
rohitjoins Dec 13, 2022
7ebab0e
Fix some release notes typos
andrewlewis Dec 14, 2022
8e8abda
Clear one-off events from state as soon as they are triggered.
tonihei Dec 14, 2022
b1e4ac4
Allow unset index and position values + remove period index
tonihei Dec 14, 2022
4f8d71e
Remove parameters with `null` values from bundle in `MediaMetadata`
rohitjoins Dec 15, 2022
9817c46
Use theme when loading drawables on API 21+
marcbaechinger Dec 15, 2022
44dbeb8
Rename `EMPTY_MEDIA_ITEM` to `PLACEHOLDER_MEDIA_ITEM`
rohitjoins Dec 16, 2022
097cdde
Clarify behavior for out-of-bounds indices and align implementations
tonihei Dec 16, 2022
da6c2df
Check if codec still exists before handling tunneling events
tonihei Dec 16, 2022
2186b6d
Avoid sending periodic position updates while paused and not loading
tonihei Dec 19, 2022
7768590
Add playlist and seek operations to SimpleBasePlayer
tonihei Dec 19, 2022
1126bbb
Remove ellipsis from Player javadoc
icbaker Dec 19, 2022
79bb53a
Fix Dackka error due to param name mismatch
icbaker Dec 19, 2022
fdc5930
Remove TODO from `ControllerInfo` - the existing approach is fine
icbaker Dec 19, 2022
9c81f3b
Add BitmapLoader injection in MediaController
tianyif Dec 19, 2022
16a67a4
Clarify some Player command and method javadoc
icbaker Dec 20, 2022
3d9fd60
Document the relationship between Player methods and available commands
icbaker Dec 20, 2022
bc82969
Add error messages to correctness assertions in SimpleBasePlayer
tonihei Dec 21, 2022
7d3375c
Fix recursive loop when registering controller visibility listeners
icbaker Dec 21, 2022
11b0baa
Update migration script
marcbaechinger Dec 21, 2022
13b72c4
Bump IMA SDK version to 3.29.0
marcbaechinger Dec 21, 2022
e07c887
Check `MediaMetadata` bundle to verify keys are skipped
rohitjoins Dec 21, 2022
0f8b861
Optimise bundling for `AdPlaybackState` using `AdPlaybackState.NONE`
rohitjoins Dec 21, 2022
a94aa8d
Fix order of playback controls in RTL layout
icbaker Dec 22, 2022
70156dc
Enable RTL support in the demo app
icbaker Dec 22, 2022
d67df79
Remove player listener on the application thread of the player
marcbaechinger Dec 22, 2022
7da071a
Check bundles in `MediaItem` to verify keys are skipped
rohitjoins Jan 4, 2023
21996be
Optimise bundling for `Timeline.Window` and `Timeline.Period`
rohitjoins Jan 4, 2023
4e7ccd7
Throw a ParserException instead of a NullPointerException if the samp…
a-googler Jan 4, 2023
2cfd05f
Fix typo in `DefaultTrackSelector.Parameters` field
rohitjoins Jan 5, 2023
96eb896
Initialise fields used for bundling as String directly
rohitjoins Jan 5, 2023
b6970c0
Update bandwidth meter estimates
tonihei Jan 10, 2023
84545e0
Add focusSkipButtonWhenAvailable to focus UI on ATV
marcbaechinger Jan 10, 2023
5d84804
Use onMediaMetadataChanged for updating the legacy session
marcbaechinger Jan 10, 2023
764daff
Improve Java doc about how to override notification drawables
marcbaechinger Jan 11, 2023
1b8608f
Request notification permission in demo app for API 33+
marcbaechinger Jan 11, 2023
2c08826
Document that `DownloadService` needs notification permissions
marcbaechinger Jan 11, 2023
b644c67
Add AdsLoader.focusSkipButton()
marcbaechinger Jan 11, 2023
a2aaad6
Catch FgSStartNotAllowedException when playback resumes
tianyif Jan 13, 2023
13dc59f
Correctly map deprecated methods in MediaController to replacement
tonihei Jan 16, 2023
55903af
Remove unneccesary parameter taking Player.Command
tonihei Jan 16, 2023
24b0367
Add missing command checks to MediaSessionLegacyStub and PlayerWrapper
tonihei Jan 16, 2023
903915d
Fix command check in MediaControllerImplBase
tonihei Jan 16, 2023
818ce72
Clarify what default settings are being used for SSAI AdsLoader
marcbaechinger Jan 16, 2023
79fd80f
Post notification for session app when FgS starting exception is caught
tianyif Jan 16, 2023
dd462e8
Filter what PlaybackStateCompat actions are advertised
christosts Jan 17, 2023
d41eede
Disables play/pause button when there's nothing to play
a-googler Jan 17, 2023
2eab93d
Make availableCommands known when bundling PlayerInfo
tonihei Jan 17, 2023
0606ab0
Fix javadoc references to `writeSampleData`
rohitjoins Jan 18, 2023
b8b6ddf
Correctly filter PlayerInfo by available getter commands.
tonihei Jan 18, 2023
5b18c2d
Extend command GET_CURRENT_MEDIA_ITEM to more methods.
tonihei Jan 19, 2023
28e3780
Update media controller position before pausing.
tonihei Jan 19, 2023
43677b9
Add command check for metadata in DefaultMediaNotificationProvider
tonihei Jan 19, 2023
967224c
Explicitly document most Player.Listener methods in terms of getters
icbaker Jan 19, 2023
107a481
Add the MediaSession as an argument to `getMediaButtons()`
marcbaechinger Jan 20, 2023
e266051
Add onSetMediaItems listener with access to start index and position
microkatz Jan 20, 2023
2adcfd9
Add missing # in release notes
christosts Jan 23, 2023
846258b
Deduplicate onSetMediaItem handler logic
microkatz Jan 24, 2023
207d67b
Suppress warnings in ImaUtil
christosts Jan 24, 2023
c357e67
Filter available commands based on PlaybackStateCompat actions
tonihei Jan 24, 2023
3708e75
Publish gradle attributes for AndroidX compatibility
icbaker Jan 25, 2023
d6c9fdb
Add missing } to publish.gradle
icbaker Jan 25, 2023
55312e1
Add missing command checks in UI module
tonihei Jan 25, 2023
5e6f79a
Tweak UI behavior when commands are missing.
tonihei Jan 27, 2023
c37442b
Match MergingMediaPeriod track selection by period index in id
microkatz Jan 27, 2023
bcdedb7
Double tap detection for Bluetooth media button events only
marcbaechinger Jan 27, 2023
631ff80
Fix timestamp comparison for seeks in fMP4
tonihei Jan 27, 2023
bfc4ed4
Inline method in PlayerService that is used from on call site only
marcbaechinger Jan 27, 2023
5528baa
Do not assume a valid queue in 3rd party sessions
marcbaechinger Jan 30, 2023
791c05b
Fix (another) `LeanbackPlayerAdapter` param name mismatch
icbaker Jan 31, 2023
d49bd45
Merge pull request #10793 from fraunhoferfokus:dash-thumbnail-support
christosts Feb 2, 2023
065418c
Publish ConcatenatingMediaSource2
marcbaechinger Feb 1, 2023
9bf18db
Session: advertise legacy FLAG_HANDLES_QUEUE_COMMANDS
christosts Feb 2, 2023
f983d91
Fix release note entry
christosts Feb 2, 2023
3fdaf78
Prepare media3 release notes for rc01
christosts Feb 13, 2023
9f43249
Minor fixes in release notes
christosts Feb 13, 2023
98bf30d
Version bump for ExoPlayer 2.18.3 & media3-1.0.0-rc01
christosts Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ body:
label: Media3 Version
description: What version of Media3 are you using?
options:
- 1.0.0-rc01
- 1.0.0-beta03
- 1.0.0-beta02
- 1.0.0-beta01
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ Android, including local playback (via ExoPlayer) and media sessions.

## Current status

AndroidX Media is currently in beta and we welcome your feedback via the
[issue tracker][]. Please consult the [release notes][] for more details about
the beta release.
AndroidX Media is currently in release candidate and we welcome your feedback
via the [issue tracker][]. Please consult the [release notes][] for more details
about the current release.

ExoPlayer's new home will be in AndroidX Media, but for now we are publishing it
both in AndroidX Media and via the existing [ExoPlayer project][]. While
AndroidX Media is in beta we recommend that production apps using ExoPlayer
continue to depend on the existing ExoPlayer project. We are still handling
ExoPlayer issues on the [ExoPlayer issue tracker][].
both in AndroidX Media and via the existing [ExoPlayer project][] and we are
still handling ExoPlayer issues on the [ExoPlayer issue tracker][].

You'll find some [Media3 documentation on developer.android.com][], including a
[migration guide for existing ExoPlayer and MediaSession users][].
Expand Down
105 changes: 101 additions & 4 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,101 @@
Release notes
# Release notes

### 1.0.0-rc01 (2023-02-16)

This release corresponds to the
[ExoPlayer 2.18.3 release](https://github.com/google/ExoPlayer/releases/tag/r2.18.3).

* Core library:
* Tweak the renderer's decoder ordering logic to uphold the
`MediaCodecSelector`'s preferences, even if a decoder reports it may not
be able to play the media performantly. For example with default
selector, hardware decoder with only functional support will be
preferred over software decoder that fully supports the format
([#10604](https://github.com/google/ExoPlayer/issues/10604)).
* Add `ExoPlayer.Builder.setPlaybackLooper` that sets a pre-existing
playback thread for a new ExoPlayer instance.
* Allow download manager helpers to be cleared
([#10776](https://github.com/google/ExoPlayer/issues/10776)).
* Add parameter to `BasePlayer.seekTo` to also indicate the command used
for seeking.
* Use theme when loading drawables on API 21+
([#220](https://github.com/androidx/media/issues/220)).
* Add `ConcatenatingMediaSource2` that allows combining multiple media
items into a single window
([#247](https://github.com/androidx/media/issues/247)).
* Extractors:
* Throw a `ParserException` instead of a `NullPointerException` if the
sample table (stbl) is missing a required sample description (stsd) when
parsing trak atoms.
* Correctly skip samples when seeking directly to a sync frame in fMP4
([#10941](https://github.com/google/ExoPlayer/issues/10941)).
* Audio:
* Use the compressed audio format bitrate to calculate the min buffer size
for `AudioTrack` in direct playbacks (passthrough).
* Text:
* Fix `TextRenderer` passing an invalid (negative) index to
`Subtitle.getEventTime` if a subtitle file contains no cues.
* SubRip: Add support for UTF-16 files if they start with a byte order
mark.
* Metadata:
* Parse multiple null-separated values from ID3 frames, as permitted by
ID3 v2.4.
* Add `MediaMetadata.mediaType` to denote the type of content or the type
of folder described by the metadata.
* Add `MediaMetadata.isBrowsable` as a replacement for
`MediaMetadata.folderType`. The folder type will be deprecated in the
next release.
* DASH:
* Add full parsing for image adaptation sets, including tile counts
([#3752](https://github.com/google/ExoPlayer/issues/3752)).
* UI:
* Fix the deprecated
`PlayerView.setControllerVisibilityListener(PlayerControlView.VisibilityListener)`
to ensure visibility changes are passed to the registered listener
([#229](https://github.com/androidx/media/issues/229)).
* Fix the ordering of the center player controls in `PlayerView` when
using a right-to-left (RTL) layout
([#227](https://github.com/androidx/media/issues/227)).
* Session:
* Add abstract `SimpleBasePlayer` to help implement the `Player` interface
for custom players.
* Add helper method to convert platform session token to Media3
`SessionToken` ([#171](https://github.com/androidx/media/issues/171)).
* Use `onMediaMetadataChanged` to trigger updates of the platform media
session ([#219](https://github.com/androidx/media/issues/219)).
* Add the media session as an argument of `getMediaButtons()` of the
`DefaultMediaNotificationProvider` and use immutable lists for clarity
([#216](https://github.com/androidx/media/issues/216)).
* Add `onSetMediaItems` callback listener to provide means to modify/set
`MediaItem` list, starting index and position by session before setting
onto Player ([#156](https://github.com/androidx/media/issues/156)).
* Avoid double tap detection for non-Bluetooth media button events
([#233](https://github.com/androidx/media/issues/233)).
* Make `QueueTimeline` more robust in case of a shady legacy session state
([#241](https://github.com/androidx/media/issues/241)).
* Metadata:
* Parse multiple null-separated values from ID3 frames, as permitted by
ID3 v2.4.
* Add `MediaMetadata.mediaType` to denote the type of content or the type
of folder described by the metadata.
* Add `MediaMetadata.isBrowsable` as a replacement for
`MediaMetadata.folderType`. The folder type will be deprecated in the
next release.
* Cast extension:
* Bump Cast SDK version to 21.2.0.
* IMA extension:
* Remove player listener of the `ImaServerSideAdInsertionMediaSource` on
the application thread to avoid threading issues.
* Add a property `focusSkipButtonWhenAvailable` to the
`ImaServerSideAdInsertionMediaSource.AdsLoader.Builder` to request
focusing the skip button on TV devices and set it to true by default.
* Add a method `focusSkipButton()` to the
`ImaServerSideAdInsertionMediaSource.AdsLoader` to programmatically
request to focus the skip button.
* Bump IMA SDK version to 3.29.0.
* Demo app:
* Request notification permission for download notifications at runtime
([#10884](https://github.com/google/ExoPlayer/issues/10884)).

### 1.0.0-beta03 (2022-11-22)

Expand Down Expand Up @@ -259,15 +356,15 @@ This release corresponds to the
* Query the platform (API 29+) or assume the audio encoding channel count
for audio passthrough when the format audio channel count is unset,
which occurs with HLS chunkless preparation
([10204](https://github.com/google/ExoPlayer/issues/10204)).
([#10204](https://github.com/google/ExoPlayer/issues/10204)).
* Configure `AudioTrack` with channel mask
`AudioFormat.CHANNEL_OUT_7POINT1POINT4` if the decoder outputs 12
channel PCM audio
([#10322](#https://github.com/google/ExoPlayer/pull/10322).
([#10322](#https://github.com/google/ExoPlayer/pull/10322)).
* DRM
* Ensure the DRM session is always correctly updated when seeking
immediately after a format change
([10274](https://github.com/google/ExoPlayer/issues/10274)).
([#10274](https://github.com/google/ExoPlayer/issues/10274)).
* Text:
* Change `Player.getCurrentCues()` to return `CueGroup` instead of
`List<Cue>`.
Expand Down
4 changes: 2 additions & 2 deletions constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
project.ext {
releaseVersion = '1.0.0-beta03'
releaseVersionCode = 1_000_000_1_03
releaseVersion = '1.0.0-rc01'
releaseVersionCode = 1_000_000_2_01
minSdkVersion = 16
appTargetSdkVersion = 33
// API version before restricting local file access.
Expand Down
2 changes: 2 additions & 0 deletions demos/main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<uses-feature android:name="android.software.leanback" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
Expand All @@ -35,6 +36,7 @@
android:largeHeap="true"
android:allowBackup="false"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:name="androidx.multidex.MultiDexApplication"
tools:targetApi="29">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
Expand All @@ -41,8 +42,10 @@
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.DoNotInline;
import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaItem.ClippingConfiguration;
Expand Down Expand Up @@ -76,13 +79,16 @@ public class SampleChooserActivity extends AppCompatActivity
private static final String TAG = "SampleChooserActivity";
private static final String GROUP_POSITION_PREFERENCE_KEY = "sample_chooser_group_position";
private static final String CHILD_POSITION_PREFERENCE_KEY = "sample_chooser_child_position";
private static final int POST_NOTIFICATION_PERMISSION_REQUEST_CODE = 100;

private String[] uris;
private boolean useExtensionRenderers;
private DownloadTracker downloadTracker;
private SampleAdapter sampleAdapter;
private MenuItem preferExtensionDecodersMenuItem;
private ExpandableListView sampleListView;
@Nullable private MediaItem downloadMediaItemWaitingForNotificationPermission;
private boolean notificationPermissionToastShown;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -172,12 +178,34 @@ public void onDownloadsChanged() {
public void onRequestPermissionsResult(
int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == POST_NOTIFICATION_PERMISSION_REQUEST_CODE) {
handlePostNotificationPermissionGrantResults(grantResults);
} else {
handleExternalStoragePermissionGrantResults(grantResults);
}
}

private void handlePostNotificationPermissionGrantResults(int[] grantResults) {
if (!notificationPermissionToastShown
&& (grantResults.length == 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
Toast.makeText(
getApplicationContext(), R.string.post_notification_not_granted, Toast.LENGTH_LONG)
.show();
notificationPermissionToastShown = true;
}
if (downloadMediaItemWaitingForNotificationPermission != null) {
// Download with or without permission to post notifications.
toggleDownload(downloadMediaItemWaitingForNotificationPermission);
downloadMediaItemWaitingForNotificationPermission = null;
}
}

private void handleExternalStoragePermissionGrantResults(int[] grantResults) {
if (grantResults.length == 0) {
// Empty results are triggered if a permission is requested while another request was already
// pending and can be safely ignored in this case.
return;
}
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
loadSample();
} else {
Toast.makeText(getApplicationContext(), R.string.sample_list_load_error, Toast.LENGTH_LONG)
Expand Down Expand Up @@ -244,15 +272,26 @@ private void onSampleDownloadButtonClicked(PlaylistHolder playlistHolder) {
if (downloadUnsupportedStringId != 0) {
Toast.makeText(getApplicationContext(), downloadUnsupportedStringId, Toast.LENGTH_LONG)
.show();
} else if (!notificationPermissionToastShown
&& Util.SDK_INT >= 33
&& checkSelfPermission(Api33.getPostNotificationPermissionString())
!= PackageManager.PERMISSION_GRANTED) {
downloadMediaItemWaitingForNotificationPermission = playlistHolder.mediaItems.get(0);
requestPermissions(
new String[] {Api33.getPostNotificationPermissionString()},
/* requestCode= */ POST_NOTIFICATION_PERMISSION_REQUEST_CODE);
} else {
RenderersFactory renderersFactory =
DemoUtil.buildRenderersFactory(
/* context= */ this, isNonNullAndChecked(preferExtensionDecodersMenuItem));
downloadTracker.toggleDownload(
getSupportFragmentManager(), playlistHolder.mediaItems.get(0), renderersFactory);
toggleDownload(playlistHolder.mediaItems.get(0));
}
}

private void toggleDownload(MediaItem mediaItem) {
RenderersFactory renderersFactory =
DemoUtil.buildRenderersFactory(
/* context= */ this, isNonNullAndChecked(preferExtensionDecodersMenuItem));
downloadTracker.toggleDownload(getSupportFragmentManager(), mediaItem, renderersFactory);
}

private int getDownloadUnsupportedStringId(PlaylistHolder playlistHolder) {
if (playlistHolder.mediaItems.size() > 1) {
return R.string.download_playlist_unsupported;
Expand Down Expand Up @@ -630,4 +669,13 @@ public PlaylistGroup(String title) {
this.playlists = new ArrayList<>();
}
}

@RequiresApi(33)
private static class Api33 {

@DoNotInline
public static String getPostNotificationPermissionString() {
return Manifest.permission.POST_NOTIFICATIONS;
}
}
}
2 changes: 2 additions & 0 deletions demos/main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

<string name="sample_list_load_error">One or more sample lists failed to load</string>

<string name="post_notification_not_granted">Notifications suppressed. Grant permission to see download notifications.</string>

<string name="download_start_error">Failed to start download</string>

<string name="download_start_error_offline_license">Failed to obtain offline license</string>
Expand Down
2 changes: 1 addition & 1 deletion demos/session/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
versionName project.ext.releaseVersion
versionCode project.ext.releaseVersionCode
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
targetSdkVersion project.ext.appTargetSdkVersion
multiDexEnabled true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.google.common.util.concurrent.ListenableFuture
class MainActivity : AppCompatActivity() {
private lateinit var browserFuture: ListenableFuture<MediaBrowser>
private val browser: MediaBrowser?
get() = if (browserFuture.isDone) browserFuture.get() else null
get() = if (browserFuture.isDone && !browserFuture.isCancelled) browserFuture.get() else null

private lateinit var mediaListAdapter: FolderMediaItemArrayAdapter
private lateinit var mediaListView: ListView
Expand Down
Loading