back button action fixed on video player
This commit is contained in:
parent
ff4d767fe2
commit
7c0312d721
1 changed files with 10 additions and 2 deletions
|
@ -21,14 +21,17 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
// url of video which we are loading.
|
// url of video which we are loading.
|
||||||
String videoURL = "https://video.asgardius.company/download/videos/41780585-a935-4d53-84c8-45ce97141231-480.mp4";
|
String videoURL = "https://video.asgardius.company/download/videos/41780585-a935-4d53-84c8-45ce97141231-480.mp4";
|
||||||
|
|
||||||
|
ExoPlayer player;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_video_player);
|
setContentView(R.layout.activity_video_player);
|
||||||
playerView = findViewById(R.id.player_view);
|
playerView = findViewById(R.id.player_view);
|
||||||
|
// creating a variable for exoplayer
|
||||||
|
player = new ExoPlayer.Builder(this).build();
|
||||||
try {
|
try {
|
||||||
// creating a variable for exoplayer
|
|
||||||
ExoPlayer player = new ExoPlayer.Builder(this).build();
|
|
||||||
// Attach player to the view.
|
// Attach player to the view.
|
||||||
playerView.setPlayer(player);
|
playerView.setPlayer(player);
|
||||||
MediaItem mediaItem = MediaItem.fromUri(videoURL);
|
MediaItem mediaItem = MediaItem.fromUri(videoURL);
|
||||||
|
@ -46,4 +49,9 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
System.out.println("Error : " + e.toString());
|
System.out.println("Error : " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onBackPressed() {
|
||||||
|
player.release();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue