问题
My video works fine but i cant controll it. I cant see play or pause button.i need play or pause button .mediaController not working fine. i using this codes
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.Display;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;
public class avid extends Activity
{
private String path = "http://techslides.com/demos/sample-videos/small.mp4";
private VideoView video_view_;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.avid);
video_view_ = (VideoView)findViewById(R.id.surface_view);
MediaController mediaController=new MediaController(this);
mediaController.setAnchorView(video_view_);
video_view_.setMediaController(mediaController);
video_view_.setVideoURI(Uri.parse(path));
video_view_.start();
}
}
layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:id="@+id/surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
/>
</FrameLayout>
i see only video . i need play or pause button here is picture enter link description here
回答1:
you can put the media controller directly in the main xml file like this :
<MediaController
android:id="@+id/mediaController1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
and normaly, when the video start, you can see the media controller.
来源:https://stackoverflow.com/questions/21151529/android-videoview-mediacontroller-pause-or-play-button