Update ExoplayerView.kt (#237)
* feat (player): added portrait mode Co-authored-by: MohammedOtaku <121404638+MohammedOtaku@users.noreply.github.com>
This commit is contained in:
parent
e915dd619d
commit
6e8bd08828
1 changed files with 27 additions and 20 deletions
|
@ -392,30 +392,37 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
||||||
}, AUDIO_CONTENT_TYPE_MOVIE, AUDIOFOCUS_GAIN)
|
}, AUDIO_CONTENT_TYPE_MOVIE, AUDIOFOCUS_GAIN)
|
||||||
|
|
||||||
if (System.getInt(contentResolver, System.ACCELEROMETER_ROTATION, 0) != 1) {
|
if (System.getInt(contentResolver, System.ACCELEROMETER_ROTATION, 0) != 1) {
|
||||||
if (PrefManager.getVal(PrefName.RotationPlayer)) {
|
if (PrefManager.getVal(PrefName.RotationPlayer)) {
|
||||||
orientationListener =
|
orientationListener =
|
||||||
object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||||
override fun onOrientationChanged(orientation: Int) {
|
override fun onOrientationChanged(orientation: Int) {
|
||||||
if (orientation in 45..135) {
|
if (orientation in 45..135) {
|
||||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) exoRotate.visibility =
|
if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
||||||
View.VISIBLE
|
exoRotate.visibility = View.VISIBLE
|
||||||
rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
|
||||||
} else if (orientation in 225..315) {
|
|
||||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) exoRotate.visibility =
|
|
||||||
View.VISIBLE
|
|
||||||
rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
||||||
|
} else if (orientation in 225..315) {
|
||||||
|
if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||||
|
exoRotate.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
|
} else if (orientation in 315..360 || orientation in 0..45) {
|
||||||
|
if (rotation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
||||||
|
exoRotate.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
rotation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
orientationListener?.enable()
|
}
|
||||||
}
|
}
|
||||||
|
orientationListener?.enable()
|
||||||
|
}
|
||||||
|
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||||
exoRotate.setOnClickListener {
|
exoRotate.setOnClickListener {
|
||||||
requestedOrientation = rotation
|
requestedOrientation = rotation
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSubFormatting(playerView)
|
setupSubFormatting(playerView)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue