我有一个活动,我想在它自己的布局中(当应用启动时)从“原始”文件夹中播放视频,而不是在任何默认应用中播放。
布局 -
<RelativeLayout 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"
android:background="#eeeeee" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="VIDEO PLAYER"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
试试这个代码:
VideoView videoview = (VideoView) findViewById(R.id.videoview);
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.splash);
videoview.setVideoURI(uri); videoview.start();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句