您可以从充气布局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