1
我的視頻正常工作,但我無法控制它。我不能看到播放或暫停button.i需要播放或暫停按鈕.mediaController不能正常工作。我使用這個代碼Android視頻媒體控制器暫停或播放按鈕
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();
}
}
佈局
<?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>
我只看到視頻。我需要播放或暫停按鈕 這裏是圖片enter link description here
你的代碼工作得很好。重新檢查..! – BlueSword