Skip to content

Commit

Permalink
Merge pull request #50 from THEOplayer/release/1.9.2
Browse files Browse the repository at this point in the history
Release 1.9.2
  • Loading branch information
MattiasBuelens authored Oct 15, 2024
2 parents 09c1fba + de4bf2b commit 2e2bbeb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
> - 🏠 Internal
> - 💅 Polish
## v1.9.2 (2024-10-15)

* 🐛 Fix `Player.cast` not available before first source change.

## v1.9.1 (2024-10-01)

* 🐛 Fix `DurationDisplay` to show the time of the live point when playing a live or DVR stream.
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ dependencies {
"mavenImplementation"("com.theoplayer.android-ui:android-ui:1.+")

implementation(libs.theoplayer)
implementation(libs.theoplayer.ads)
implementation(libs.theoplayer.ads.ima)
implementation(libs.theoplayer.cast)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ android.nonTransitiveRClass=true
android.nonFinalResIds=true
org.gradle.configuration-cache=true
# The version of the THEOplayer Open Video UI for Android.
version=1.9.1
version=1.9.2
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ androidx-junit = "1.2.1"
androidx-espresso = "3.6.1"
androidx-mediarouter = "1.7.0"
dokka = "1.9.20"
theoplayer = "7.11.0"
theoplayer = "8.2.0"

[libraries]
androidx-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktx" }
Expand All @@ -39,7 +39,6 @@ dokka-plugin = { group = "org.jetbrains.dokka", name = "android-documentation-pl
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-gradle-plugin" }
junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
theoplayer = { group = "com.theoplayer.theoplayer-sdk-android", name = "core", version.ref = "theoplayer" }
theoplayer-ads = { group = "com.theoplayer.theoplayer-sdk-android", name = "integration-ads", version.ref = "theoplayer" }
theoplayer-ads-ima = { group = "com.theoplayer.theoplayer-sdk-android", name = "integration-ads-ima", version.ref = "theoplayer" }
theoplayer-cast = { group = "com.theoplayer.theoplayer-sdk-android", name = "integration-cast", version.ref = "theoplayer" }

Expand Down
39 changes: 27 additions & 12 deletions ui/src/main/java/com/theoplayer/android/ui/Player.kt
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ enum class StreamType {
internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player {
override val player = theoplayerView?.player
override val ads = theoplayerView?.player?.ads
override var cast by mutableStateOf<Cast?>(null)
private set
override var currentTime by mutableStateOf(0.0)
private set
override var duration by mutableStateOf(Double.NaN)
Expand Down Expand Up @@ -368,8 +366,6 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
_source = player?.source
error = null
firstPlay = false
// The cast integration is only registered *after* rememberPlayer() is called,
// so it's not available at construction time. Check if it's available now.
updateCast(theoplayerView?.cast)
updateCurrentTimeAndPlaybackState()
updateDuration()
Expand Down Expand Up @@ -612,12 +608,31 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
private val textTrackListChangeListener =
EventListener<TextTrackListChangeEvent> { updateActiveSubtitleTrack() }

override var castState: PlayerCastState by mutableStateOf(PlayerCastState.UNAVAILABLE)
override var castReceiverName: String? by mutableStateOf(null)
private var _cast by mutableStateOf<Cast?>(null)
private var _castState: PlayerCastState by mutableStateOf(PlayerCastState.UNAVAILABLE)
private var _castReceiverName: String? by mutableStateOf(null)
override val cast: Cast?
get() {
// The cast integration is only registered *after* rememberPlayer() is called,
// so it might not be available at construction time.
// Always use the getter on THEOplayerView to get the current cast integration.
updateCast(theoplayerView?.cast)
return _cast
}
override val castState: PlayerCastState
get() {
updateCast(theoplayerView?.cast)
return _castState
}
override val castReceiverName: String?
get() {
updateCast(theoplayerView?.cast)
return _castReceiverName
}

private fun updateCast(cast: Cast?) {
if (this.cast == cast) return
this.cast?.let { oldCast ->
if (_cast == cast) return
_cast?.let { oldCast ->
oldCast.chromecast.removeEventListener(
ChromecastEventTypes.STATECHANGE,
chromecastStateChangeListener
Expand All @@ -627,7 +642,7 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
chromecastErrorListener
)
}
this.cast = cast
_cast = cast
cast?.let {
cast.chromecast.addEventListener(
ChromecastEventTypes.STATECHANGE,
Expand All @@ -639,8 +654,8 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
}

private fun updateCastState() {
castState = cast?.chromecast?.state ?: PlayerCastState.UNAVAILABLE
castReceiverName = cast?.chromecast?.receiverName
_castState = cast?.chromecast?.state ?: PlayerCastState.UNAVAILABLE
_castReceiverName = cast?.chromecast?.receiverName
}

private val chromecastStateChangeListener =
Expand All @@ -657,6 +672,7 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
updateActiveVideoTrack()
updateAudioTracks()
updateSubtitleTracks()
updateCast(theoplayerView?.cast)
updateCastState()
player?.addEventListener(PlayerEventTypes.PLAY, playListener)
player?.addEventListener(PlayerEventTypes.PAUSE, pauseListener)
Expand Down Expand Up @@ -710,7 +726,6 @@ internal class PlayerImpl(override val theoplayerView: THEOplayerView?) : Player
ads?.addEventListener(AdsEventTypes.AD_BREAK_BEGIN, adListener)
ads?.addEventListener(AdsEventTypes.AD_SKIP, adListener)
ads?.addEventListener(AdsEventTypes.AD_BREAK_END, adListener)
updateCast(theoplayerView?.cast)
fullscreenHandler?.onFullscreenChangeListener = fullscreenListener
}

Expand Down

0 comments on commit 2e2bbeb

Please sign in to comment.