fix video layout switch

This commit is contained in:
Page Asgardius 2022-10-09 12:35:53 -07:00
parent 307e1253de
commit f6165c6d6c
2 changed files with 22 additions and 7 deletions

View file

@ -88,7 +88,7 @@
android:name=".VideoPlayer"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|uiMode|keyboardHidden"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout|uiMode|keyboardHidden"
android:exported="false"
android:theme="@style/Theme.AsgardiusS3Manager.NoActionBar" />
<activity

View file

@ -20,8 +20,6 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
@ -204,7 +202,18 @@ public class VideoPlayer extends AppCompatActivity {
playerView.setPlayer(null);
player.release();
super.onDestroy();
}
public void onStop() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& this.getPackageManager()
.hasSystemFeature(
PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
simpleCache.release();
playerView.setPlayer(null);
player.release();
}
super.onStop();
}
public void onUserLeaveHint() {
@ -212,8 +221,14 @@ public class VideoPlayer extends AppCompatActivity {
enterPIPMode();
}
/*public void onBackPressed() {
player.release();
finish();
}*/
public void onBackPressed() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& this.getPackageManager()
.hasSystemFeature(
PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
enterPIPMode();
} else {
super.onBackPressed();
}
}
}