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:name=".VideoPlayer"
android:resizeableActivity="true" android:resizeableActivity="true"
android:supportsPictureInPicture="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:exported="false"
android:theme="@style/Theme.AsgardiusS3Manager.NoActionBar" /> android:theme="@style/Theme.AsgardiusS3Manager.NoActionBar" />
<activity <activity

View file

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