2017-03-21 11 views
-1

https://youtu.be/ejM49vbUU3cは、私は昼食にアプリ

これは私が をしたいとどのようにすべてのデバイスのためにそれを設定するには、ロゴである前に、最初の5秒をしたいですか? は、私は食欲それ

+0

このビデオをスプラッシュ画面の 'videoview'で実行します。 –

答えて

0

SplashActivityと呼ばれる自分のアプリに別のアクティビティを追加し、ビデオを設定し、この活動ののonCreateメソッドでビデオを再生し、あなたに感謝し、videoViewにonCompleteListenerを設定し、ビデオの再生はMainActivityを開始し終了したとき。

import android.app.Activity; 
import android.content.Intent; 
import android.media.MediaPlayer; 
import android.net.Uri; 
import android.os.Bundle; 
import android.widget.VideoView; 

public class SplashActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.activity_splash); 

    VideoView videoView = (VideoView) findViewById(R.id.video_view); 

    Uri videoUri = Uri.parse("android.resource://ir.ugstudio.playvideo/raw/video1"); 
    videoView.setVideoURI(videoUri); 

    videoView.start(); 

    videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
     @Override 
     public void onCompletion(MediaPlayer mediaPlayer) { 
      startActivity(new Intent(SplashActivity.this, MainActivity.class)); 
     } 
    }); 
} 
} 

これは

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<VideoView 
    android:id="@+id/video_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

</LinearLayout> 

activity_splash.xml "RES" フォルダ内の "生" という名前のフォルダを作成し、その中で自分の "ビデオ1" を入れています。

関連する問題