80,472
社区成员




Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/001.mp4");
MyVideoView videoView = (MyVideoView) this.findViewById(R.id.videoView1);
videoView.setVideoURI(uri);
videoView.start();
MyVideoView videoView2 = (MyVideoView) this.findViewById(R.id.videoView2);
videoView2.setVideoURI(uri);
videoView2.start();
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:orientation="vertical"
android:layout_marginLeft="50dp"
android:layout_marginTop="50dp"
android:background="#E820D4"
>
<com.example.test.MyVideoView
android:id="@+id/videoView1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="0dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:orientation="vertical"
android:layout_marginLeft="300dp"
android:layout_marginTop="50dp"
android:background="#20E827"
>
<com.example.test.MyVideoView
android:id="@+id/videoView2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="0dp"
/>
</LinearLayout>
</FrameLayout>
public class MyVideoView extends VideoView {
public MyVideoView(Context context) {
super(context);
}
public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = 700;
int height = 400;
setMeasuredDimension(width, height);
}
}