back button action fixed on video player

This commit is contained in:
Page Asgardius 2022-08-27 19:36:24 -07:00
parent ff4d767fe2
commit 7c0312d721

View file

@ -21,14 +21,17 @@ public class VideoPlayer extends AppCompatActivity {
// url of video which we are loading.
String videoURL = "https://video.asgardius.company/download/videos/41780585-a935-4d53-84c8-45ce97141231-480.mp4";
ExoPlayer player;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player);
playerView = findViewById(R.id.player_view);
try {
// creating a variable for exoplayer
ExoPlayer player = new ExoPlayer.Builder(this).build();
player = new ExoPlayer.Builder(this).build();
try {
// Attach player to the view.
playerView.setPlayer(player);
MediaItem mediaItem = MediaItem.fromUri(videoURL);
@ -46,4 +49,9 @@ public class VideoPlayer extends AppCompatActivity {
System.out.println("Error : " + e.toString());
}
}
public void onBackPressed() {
player.release();
finish();
}
}