bump media3 version

This commit is contained in:
Gary Wang 2022-03-17 23:44:15 +08:00
parent c6e107fdd0
commit 1b2b40b64a
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760
2 changed files with 17 additions and 2 deletions

View File

@ -78,7 +78,7 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:4.9.0"
def media3_version = '1.0.0-alpha02'
def media3_version = '1.0.0-alpha03'
implementation "androidx.media3:media3-ui:$media3_version"
implementation "androidx.media3:media3-exoplayer:$media3_version"
implementation "androidx.media3:media3-session:$media3_version"

View File

@ -59,6 +59,21 @@ class PlaybackService : MediaLibraryService() {
}
}
class CustomMediaItemFiller : MediaSession.MediaItemFiller {
override fun fillInLocalConfiguration(
session: MediaSession,
controller: MediaSession.ControllerInfo,
mediaItem: MediaItem
): MediaItem {
// Return the media item that it will be played
return MediaItem.Builder()
// Use the metadata values to fill our media item
.setUri(mediaItem.mediaMetadata.mediaUri)
.setMediaMetadata(mediaItem.mediaMetadata)
.build()
}
}
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession {
return mediaLibrarySession
}
@ -92,7 +107,7 @@ class PlaybackService : MediaLibraryService() {
mediaLibrarySession =
MediaLibrarySession.Builder(this, player, librarySessionCallback)
// .setMediaItemFiller(CustomMediaItemFiller())
.setMediaItemFiller(CustomMediaItemFiller())
.setSessionActivity(pendingIntent!!)
.build()
}