diff --git a/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt b/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt index 1ccfe3f..caa19b3 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt @@ -41,6 +41,7 @@ import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.Disposable +import io.reactivex.subjects.BehaviorSubject import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -214,8 +215,10 @@ internal class ArmadilloPlayerChoreographer : ArmadilloPlayer { /** * emits the most recently emitted state and all the subsequent states when an observer subscribes to it. */ + val armadilloStateSubject: BehaviorSubject + get() = stateProvider.stateSubject override val armadilloStateObservable: Observable - get() = stateProvider.stateSubject.observeOn(AndroidSchedulers.mainThread()) + get() = armadilloStateSubject.observeOn(AndroidSchedulers.mainThread()) private val pollingInterval = Observable.interval(observerPollIntervalMillis.longValue, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) @@ -439,7 +442,7 @@ internal class ArmadilloPlayerChoreographer : ArmadilloPlayer { data class PlaybackReadyData(val transportControls: MediaControllerCompat.TransportControls?, val engineIsReady: Boolean) Log.d(TAG, "Waiting for engine before invoking callback") - disposables.add(armadilloStateObservable + disposables.add(armadilloStateSubject .map { PlaybackReadyData(playbackConnection?.transportControls, it.internalState.isPlaybackEngineReady) } diff --git a/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt b/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt index 4757353..79c5753 100644 --- a/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt +++ b/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt @@ -55,7 +55,7 @@ class ArmadilloPlayerChoreographerTest { whenever(stateProvider.stateSubject).thenReturn(stateSubject) choreographer.stateProvider = stateProvider - assertThat(choreographer.armadilloStateObservable.value).isEqualTo(state) + assertThat(choreographer.armadilloStateSubject.value).isEqualTo(state) } @Test