2014-09-06 70 views
-4

我有一個活動,我想在其自己的佈局(當應用程序啓動時)不在任何默認應用程序中播放「raw」文件夾中的視頻。在佈局中播放mp4 android

佈局 -

<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> 
+1

什麼錯誤? – KOTIOS 2014-09-06 12:49:53

+1

視頻觀看你高速寫入..u也會絞碎代碼來播放它..不是嗎? – KOTIOS 2014-09-06 12:54:02

+1

好吧,基本上它是一個videoView和你想玩嗎? – KOTIOS 2014-09-06 12:57:17

回答

1

試試這個代碼:從上面的代碼

 VideoView videoview = (VideoView) findViewById(R.id.videoview); 
    Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.splash); 
    videoview.setVideoURI(uri); videoview.start();