From 46fb454b3ffc4b2ad97ceccb4dc798e1c9a4c774 Mon Sep 17 00:00:00 2001 From: bachinger Date: Mon, 22 May 2023 21:36:35 +0100 Subject: [PATCH] Add artwork display mode to PlayerView This change deprecates `PlayerView.setUseArtwork(boolean)` and introduces `setArtworkDisplayMode(mode)` and `artworkDisplayMode="off|fit|fill"` instead. - off: no artwork is displayed (like deprecated useArtwork=false) - fit: letterbox like media (like deprecated useArtwork=true) - fill: scales the artwork to fill the entire width/weight of the player view #minor-release PiperOrigin-RevId: 534167226 --- RELEASENOTES.md | 2 + demos/session/src/main/assets/catalog.json | 88 +++++++++++++++++++ .../java/androidx/media3/ui/PlayerView.java | 85 ++++++++++++++---- libraries/ui/src/main/res/values/attrs.xml | 6 ++ 4 files changed, 164 insertions(+), 17 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 48976897bd..c5e0ae25ff 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -39,6 +39,8 @@ example, a Bluetooth headset ([#167](https://github.com/androidx/media/issues/167)). * UI: + * Deprecate `PlayerView.setUseArtwork(boolean)` and replace it with + `PlayerView.setArtworkDisplayMode(@ArtworkDisplayMode)`. * Downloads: * OkHttp Extension: * Cronet Extension: diff --git a/demos/session/src/main/assets/catalog.json b/demos/session/src/main/assets/catalog.json index e336999b1d..d5b9286d7c 100644 --- a/demos/session/src/main/assets/catalog.json +++ b/demos/session/src/main/assets/catalog.json @@ -501,6 +501,94 @@ "totalTrackCount": 2, "duration": 160, "site": "https://www.youtube.com/audiolibrary/music" + }, + { + "id": "mixed_media_01", + "title": "Tear of steal - DASH", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/wvmedia/clear/h264/tears/tears.mpd", + "image": "https://storage.googleapis.com/wvmedia/clear/h264/tears/tears.mpd" + }, + { + "id": "mixed_media_02", + "title": "Intro - The Way Of Waking Up (feat. Alan Watts - MP3)", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/01_-_Intro_-_The_Way_Of_Waking_Up_feat_Alan_Watts.mp3", + "image": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/art.jpg" + }, + { + "id": "mixed_media_03", + "title": "TTML Netflix Japanese examples (MP4)", + "source": "https://storage.googleapis.com/exoplayer-test-media-1/gen-3/screens/dash-vod-single-segment/video-avc-baseline-480.mp4", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "image": "https://cdn.pixabay.com/photo/2014/10/09/13/14/video-481821_960_720.png", + "subtitles": [ + { + "subtitle_uri": "https://storage.googleapis.com/exoplayer-test-media-1/ttml/netflix_japanese_ttml.xml", + "subtitle_mime_type": "application/ttml+xml", + "subtitle_lang": "ja" + } + ] + }, + { + "id": "mixed_media_04", + "title": "The Coldest Shoulder", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/automotive-media/The_Coldest_Shoulder.mp3", + "image": "https://storage.googleapis.com/automotive-media/album_art_3.jpg" + }, + { + "id": "mixed_media_05", + "title": "Dizzy - MPEG-4 Timed Text", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/exoplayer-test-media-1/mp4/dizzy-with-tx3g.mp4", + "image": "https://cdn.pixabay.com/photo/2014/10/09/13/14/video-481821_960_720.png" + }, + { + "id": "mixed_media_06", + "title": "Apple 4x3 basic stream (TS)", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8", + "image": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/art.jpg" + }, + { + "id": "mixed_media_07", + "title": "The Calm Before The Storm", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/05_-_The_Calm_Before_The_Storm.mp3", + "image": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/art.jpg" + }, + { + "id": "mixed_media_08", + "title": "Android screens (MKV)", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/exoplayer-test-media-1/mkv/android-screens-lavf-56.36.100-aac-avc-main-1280x720.mkv", + "image": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/art.jpg" + }, + { + "id": "mixed_media_09", + "title": "No Pain, No Gain", + "album": "Mixed media", + "artist": "Mixed artists", + "genre": "Mixed", + "source": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/06_-_No_Pain_No_Gain.mp3", + "image": "https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/art.jpg" } ] } diff --git a/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java b/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java index 6b6b9a7cb3..d732c2a753 100644 --- a/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java +++ b/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java @@ -93,10 +93,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; * The following attributes can be set on a PlayerView when used in a layout XML file: * *