Skip to content

Commit

Permalink
fix(android): Allow updating duration in notification (#2157)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz authored Oct 10, 2023
1 parent 4b859e8 commit e28536c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repositories {
}

dependencies {
implementation 'com.github.doublesymmetry:kotlinaudio:v2.0.0-rc15'
implementation 'com.github.doublesymmetry:kotlinaudio:v2.0.0-rc16'
// used when building against local maven
// implementation "com.github.doublesymmetry:kotlin-audio:1.2.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ data class TrackAudioItem(
override var title: String? = null,
override var albumTitle: String? = null,
override val artwork: String? = null,
override val duration: Long = -1,
override val duration: Long? = null,
override val options: AudioItemOptions? = null
): AudioItem
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class TrackMetadata {
var album: String? = null
var date: String? = null
var genre: String? = null
var duration: Long = 0
var duration: Long? = null
var rating: RatingCompat? = null
open fun setMetadata(context: Context, bundle: Bundle?, ratingType: Int) {
artwork = BundleUtils.getUri(context, bundle, "artwork")
Expand All @@ -23,7 +23,13 @@ abstract class TrackMetadata {
album = bundle.getString("album")
date = bundle.getString("date")
genre = bundle.getString("genre")
duration = (bundle.getDouble("duration", 0.0)).toMilliseconds()

duration = if (bundle.containsKey("duration")) {
bundle.getDouble("duration").toMilliseconds()
} else {
null
}

rating = BundleUtils.getRating(bundle, "rating", ratingType)
}
}
1 change: 1 addition & 0 deletions example/src/components/ActionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const onUpdateCurrentTrackMetadata = async () => {
await TrackPlayer.updateMetadataForTrack(currentTrackIndex, {
title: `Random: ${randomTitle}`,
artwork: `https://random.imagecdn.app/800/800?dummy=${Date.now()}`,
duration: Math.floor(Math.random()),
});
}
};
Expand Down

0 comments on commit e28536c

Please sign in to comment.