@gogogodeng
2017-08-10T13:43:20.000000Z
字数 1009
阅读 515
android控件
播放音视频的控件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/videoView"
android:layout_gravity="center_horizontal"
android:layout_centerInParent="true" />
</LinearLayout>
package com.testapp.app;
import android.app.Activity;
import android.os.Bundle;
import android.net.Uri;
import android.widget.VideoView;
/**
* Created by develop on 2015/11/17.
*/
public class VideoViewActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoview);
// 开启新的线程
Thread t=new Thread(new Runnable() {
@Override
public void run() {
VideoView vv = (VideoView)findViewById(R.id.videoView);
vv.setVideoURI(Uri.parse("http://192.168.1.254/UploadFiles/d/test.mp4"));
vv.start();
}
});
t.start();
}
}
不开启新线程就报错