From 7c0312d721276a212e1aa24eb2c9698f0cd1d4d4 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 27 Aug 2022 19:36:24 -0700 Subject: [PATCH] back button action fixed on video player --- .../java/asgardius/page/s3manager/VideoPlayer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java index e4f750b..552af46 100644 --- a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java +++ b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java @@ -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); + // creating a variable for exoplayer + player = new ExoPlayer.Builder(this).build(); try { - // creating a variable for exoplayer - ExoPlayer player = new ExoPlayer.Builder(this).build(); + // 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(); + } } \ No newline at end of file