我有 4 个需要在 Android 应用中播放的 .mp4 视频。我设法播放了 1 个视频,但其他 3 个无法播放。我认为视频大小是问题所在。我设法播放的视频大小为 1.4mb,其他 3 个大小为 6mb、2.2mb、3.8mb。
这是我播放它们的代码。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_videoviewer);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String value = extras.getString("VidName");
if(value.equals("MinorBurnVid"))
{
try
{
videoView1 = (VideoView)findViewById(R.id.Video1);
videoView1.setVideoPath("android.resource://dr.droid/" + R.raw.burn);
videoView1.setMediaController(new MediaController(this));
videoView1.requestFocus();
videoView1.start();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
else if(value.equals("ChokingAdultVid"))
{
try
{
videoView1 = (VideoView)findViewById(R.id.Video1);
videoView1.setVideoPath("android.resource://dr.droid/" + R.raw.chokingadult);
videoView1.setMediaController(new MediaController(this));
videoView1.requestFocus();
videoView1.start();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
else if(value.equals("CPRAdultVid"))
{
try
{
videoView1 = (VideoView)findViewById(R.id.Video1);
videoView1.setVideoPath("android.resource://dr.droid/" + R.raw.cpr);
videoView1.setMediaController(new MediaController(this));
videoView1.requestFocus();
videoView1.start();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
else if(value.equals("Fracture"))
{
try
{
videoView1 = (VideoView)findViewById(R.id.Video1);
videoView1.setVideoPath("android.resource://dr.droid/" + R.raw.fracture);
videoView1.setMediaController(new MediaController(this));
videoView1.requestFocus();
videoView1.start();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
}
}
刻录视频是我设法播放的一个,但其他 3 个,没有运气!有任何想法吗?