您可以從充氣佈局XML中的MediaController。另外,獲得參考後,可以將視頻視圖設置爲主播。
- 但這將盡快導致崩潰,當你試圖去觸摸 的MediaController(我想弄清楚,爲什麼它的發生)。
此外mediaController會一直出現。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/mVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<MediaController
android:id="@+id/mediaController1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusable="false"
android:focusableInTouchMode="false"/>
</RelativeLayout>
在活動中,
public class AnimationActivity extends Activity implements OnClickListener {
private MediaController mController = null;
private VideoView mVideoView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animation);
mController = (MediaController) findViewById(R.id.mediaController1);
mController.post(new Runnable() {
@Override
public void run() {
mVideoView = (VideoView) findViewById(R.id.mVideoView);
mVideoView.setVideoURI(Uri.parse("android.resource://"
+ getPackageName() + "/" + R.raw.video0));
mController.setAnchorView(mVideoView);
mVideoView.setSoundEffectsEnabled(false);
mVideoView.start();
}
});
}
}
ctlr.show(0)確實顯示控制器,直到隱藏被稱爲先生 – 2014-03-23 11:14:31