Skip to content

Commit d824a50

Browse files
Merge pull request #322 from THEOplayer/adobe/android-playhead
Adobe/android playhead
2 parents 2fe70b3 + 22cfc65 commit d824a50

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.changeset/spotty-cameras-run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@theoplayer/react-native-analytics-adobe': patch
3+
---
4+
5+
Fixed an issue on Android where the playhead for Live events would exceed the maximum value.

adobe/android/src/main/java/com/theoplayer/reactnative/adobe/AdobeConnector.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import kotlin.collections.orEmpty
4444
import kotlin.collections.plus
4545
import kotlin.collections.toMutableMap
4646
import kotlinx.serialization.json.*
47+
import java.util.Calendar
4748

4849
typealias AddTextTrackEvent = com.theoplayer.android.api.event.track.texttrack.list.AddTrackEvent
4950
typealias RemoveTextTrackEvent = com.theoplayer.android.api.event.track.texttrack.list.RemoveTrackEvent
@@ -371,8 +372,14 @@ class AdobeConnector(
371372
}
372373

373374
private fun getCurrentTime(): Int {
374-
return when (player.currentTime) {
375-
Double.POSITIVE_INFINITY -> (System.currentTimeMillis() / 1000) % 86400
375+
return when (player.duration) {
376+
Double.POSITIVE_INFINITY -> {
377+
// Return seconds since start of day for live streams
378+
val calendar = Calendar.getInstance()
379+
calendar.get(Calendar.SECOND) +
380+
60 * (calendar.get(Calendar.MINUTE) +
381+
60 * calendar.get(Calendar.HOUR_OF_DAY))
382+
}
376383
else -> player.currentTime
377384
}.toInt()
378385
}

0 commit comments

Comments
 (0)