File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed
data/src/main/java/com/my/kizzy/data/get_current_data Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -26,16 +26,11 @@ class AppTracker @Inject constructor(
26
26
private val getCurrentlyRunningApp : GetCurrentlyRunningApp ,
27
27
private val getCurrentPlayingMedia : GetCurrentPlayingMedia
28
28
) {
29
-
30
29
fun getCurrentAppData () = flow {
31
- var songTitle = " " // Title::packageName
32
30
while (currentCoroutineContext().isActive) {
33
31
val getCurrentMedia = getCurrentPlayingMedia()
34
32
if (getCurrentMedia.name.isNotEmpty()) {
35
- if (songTitle != getCurrentMedia.packageName) {
36
- songTitle = getCurrentMedia.packageName
37
- emit(getCurrentMedia)
38
- }
33
+ emit(getCurrentMedia)
39
34
} else {
40
35
val getCurrentApp = getCurrentlyRunningApp()
41
36
if (getCurrentApp.name.isNotEmpty()) {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import android.content.ComponentName
17
17
import android.content.Context
18
18
import android.media.MediaMetadata
19
19
import android.media.session.MediaSessionManager
20
+ import android.media.session.PlaybackState.STATE_PLAYING
20
21
import com.blankj.utilcode.util.AppUtils
21
22
import com.my.kizzy.data.rpc.CommonRpc
22
23
import com.my.kizzy.data.rpc.RpcImage
@@ -53,7 +54,7 @@ class GetCurrentPlayingMedia @Inject constructor(
53
54
val bitmap = metadata?.let { metadataResolver.getCoverArt(it) }
54
55
val duration = metadata?.getLong(MediaMetadata .METADATA_KEY_DURATION )
55
56
duration?.let {
56
- if (it != 0L ) timestamps = Timestamps (
57
+ if (it != 0L && mediaController.playbackState?.state == STATE_PLAYING ) timestamps = Timestamps (
57
58
end = System .currentTimeMillis() + duration - (mediaController.playbackState?.position ? : 0L ),
58
59
start = System .currentTimeMillis() - (mediaController.playbackState?.position ? : 0L )
59
60
)
You can’t perform that action at this time.
0 commit comments