Skip to content

Commit

Permalink
updated video controller into the video view
Browse files Browse the repository at this point in the history
  • Loading branch information
codephillip committed May 6, 2020
1 parent 76c7cab commit 2a4ab8f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.unfpa.safepal;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -23,6 +24,7 @@ public class WatchVideoActivity extends AppCompatActivity {
private TextView description;
private RecyclerView relatedVideosRecyclerView;
private VideoAdapter videoAdapter;
private MediaController mediaController;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -50,7 +52,12 @@ protected void onCreate(Bundle savedInstanceState) {
video.setMediaController(new MediaController(this));
video.setVideoURI(Uri.parse(videotableCursor.getUrl()));
video.requestFocus();
video.setOnPreparedListener(mp -> video.start());
video.setOnPreparedListener(mp -> {
mediaController = new MediaController(WatchVideoActivity.this);
video.setMediaController(mediaController);
mediaController.setAnchorView(video);
video.start();
});

videoAdapter = new VideoAdapter(this, new VideotableSelection()
.orderByCreatedAt(true).category(videotableCursor.getCategory())
Expand Down

0 comments on commit 2a4ab8f

Please sign in to comment.