diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 447f538c..cfcdb8c7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,6 +25,7 @@
+ val windowInsetsController = ViewCompat.getWindowInsetsController(window.decorView)
+ if (!fullscreen) {
+ // Configure the behavior of the hidden system bars
+ windowInsetsController?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
+ // Hide both the status bar and the navigation bar
+ windowInsetsController?.show(WindowInsetsCompat.Type.systemBars())
+ supportActionBar?.show()
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
+ } else {
+ // Configure the behavior of the hidden system bars
+ windowInsetsController?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
+ // Hide both the status bar and the navigation bar
+ windowInsetsController?.hide(WindowInsetsCompat.Type.systemBars())
+
+ requestedOrientation =
+ if (mediaPlayer.videoSize.height < mediaPlayer.videoSize.width) {
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+ } else {
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ }
+ supportActionBar?.hide()
+ }
+ }
+
+ // Configure audio
+ mediaPlayer.setAudioAttributes(AudioAttributesCompat.Builder()
+ .setLegacyStreamType(STREAM_MUSIC)
+ .setUsage(AudioAttributesCompat.USAGE_MEDIA)
+ .setContentType(AudioAttributesCompat.CONTENT_TYPE_MOVIE)
+ .build()
+ )
+
mediaPlayer.prepare()
binding.videoView.setPlayer(mediaPlayer)
@@ -48,4 +89,14 @@ class MediaViewerActivity : BaseActivity() {
// Start actually playing the video
mediaPlayer.play()
}
+
+ override fun onPause() {
+ super.onPause()
+ mediaPlayer.pause()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ mediaPlayer.close()
+ }
}
\ No newline at end of file