Last active
January 22, 2019 01:36
-
-
Save Bradleycorn/0f4ab5476e33638be038edee9fa9a539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityViewModel: ViewModel() { | |
val videoUrl = "https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8" | |
enum class VideoPlaybackState { | |
STOPPED, | |
PLAYING | |
} | |
enum class VideoLayoutState { | |
EMBEDDED, | |
FULLSCREEN, | |
PIP | |
} | |
private var showInPipMode = false | |
private var currentOrientation: Int = Configuration.ORIENTATION_UNDEFINED | |
private val _playbackState = MutableLiveData<VideoPlaybackState>().apply { | |
value = VideoPlaybackState.STOPPED | |
} | |
val playbackState: LiveData<VideoPlaybackState> = _playbackState | |
private val _layoutState = MutableLiveData<VideoLayoutState>().apply { | |
value = VideoLayoutState.EMBEDDED | |
} | |
val layoutState: LiveData<VideoLayoutState> = Transformations.map(_layoutState) { newState -> | |
showInPipMode = when (newState) { | |
VideoLayoutState.PIP -> true | |
VideoLayoutState.EMBEDDED -> false | |
else -> showInPipMode | |
} | |
return@map newState | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment