Skip to content

Instantly share code, notes, and snippets.

@Bradleycorn
Created January 22, 2019 02:14
Show Gist options
  • Save Bradleycorn/485fd69a5b880058ef5fa24510bcd685 to your computer and use it in GitHub Desktop.
Save Bradleycorn/485fd69a5b880058ef5fa24510bcd685 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
private val viewModel: MainActivityViewModel by viewModels()
private val videoPlayerCallbacks = object: ControlledVideoView.IVideoListener {
override fun onPipToggleClicked() {
viewModel.onPipToggled()
}
override fun onVideoCloseClicked() {
viewModel.onVideoClosed()
}
override fun onVideoFullScreenClicked(isFullScreen: Boolean) {
//isFullScreen = true means we're already in fullscreen,
// so we want to turn it off and lock to portrait. And Vice Versa
val orientationLock = when (isFullScreen) {
true -> Configuration.ORIENTATION_PORTRAIT
false -> Configuration.ORIENTATION_LANDSCAPE
}
viewModel.onOrientationForced(orientationLock)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment