diff --git a/connectors/mediasession/src/main/java/com/theoplayer/android/connector/mediasession/MediaMetadataProvider.kt b/connectors/mediasession/src/main/java/com/theoplayer/android/connector/mediasession/MediaMetadataProvider.kt index 15bd022d..cbaecaf6 100644 --- a/connectors/mediasession/src/main/java/com/theoplayer/android/connector/mediasession/MediaMetadataProvider.kt +++ b/connectors/mediasession/src/main/java/com/theoplayer/android/connector/mediasession/MediaMetadataProvider.kt @@ -70,10 +70,7 @@ class MediaMetadataProvider(private val connector: MediaSessionConnector) { clearMediaSessionMetadataDescription() return } - builder.putLong( - MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, - if (player.ads.isPlaying) 1 else 0 - ) + setAdvertisement(player.ads.isPlaying) if (!java.lang.Double.isNaN(player.duration)) { setDuration((1e03 * player.duration).toLong()) } @@ -91,6 +88,13 @@ class MediaMetadataProvider(private val connector: MediaSessionConnector) { connector.mediaSession.setMetadata(METADATA_EMPTY) } + /** + * See [MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT]. + */ + fun setAdvertisement(value: Boolean?) { + builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, if (value == true) 1 else 0) + } + /** * See [MediaMetadataCompat.METADATA_KEY_ALBUM]. */