我的应用程序中有一个 splahs 屏幕,我正在播放有关该活动的视频。但在某些 Android 版本(我的意思是旧版本)中,视频无法播放。我不知道该怎么办..
这是我的一些代码
public void PlayVideo(){
try{
videoPlayer.setDataSource(getApplicationContext(), Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.afad_splash_ip4));
videoPlayer.prepare();
}
catch (Exception e){
}
try {
AssetFileDescriptor descriptor = getAssets().openFd("splash.mp4");
videoPlayer.reset();
videoPlayer.setDataSource(descriptor.getFileDescriptor());
videoPlayer.prepare();
}
catch (Exception ex)
{
try
{
Log.v("video ", "catch");
videoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
videoPlayer.setVolume(0f, 0f);
videoPlayer.start();
videoPlayer.setLooping(false);
videoPlayer.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
Intent i = new Intent(VideoSplash.this,ListActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
overridePendingTransition(R.anim.slide_in_top,R.anim.slide_out_bottom);
finish();
}
});
}
catch (Exception e)
{ //TODO
//Burada Video yerine resim koymalısın
//Kimi cihazlarda video oynamayabilir
Log.v("resim", "catch");
//Thats where i want to put a pic as a backgroun to my SurfaceView. and make it wait 10 secs
// videoSurface.setBackgroundDrawable(getResources().getDrawable(R.drawable.son_frame));
}
//TODO
//Burada Video yerine resim koymalısın
//Kimi cihazlarda video oynamayabilir
}
}