Videoview 在线播放

来源:互联网 发布:双代号施工网络计划 编辑:程序博客网 时间:2024/04/19 23:40


package com.example.videoview;    import android.app.Activity;  import android.net.Uri;  import android.os.Bundle;  import android.widget.VideoView;    public class MainActivity extends Activity {        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);            VideoView videoView = (VideoView) findViewById(R.id.videoView);            videoView.setVideoURI(Uri.parse("http://xxx.xxx/xxx.mp4"));            // 开始播放视频          videoView.start();            // VideiView获焦点          // videoView.requestFocus();      }  }  

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.example.videoview.MainActivity" >    <VideoView        android:id="@+id/videoView"        android:layout_width="match_parent"        android:layout_height="match_parent" /></FrameLayout>


0 0
原创粉丝点击