0

我有 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 个,没有运气!有任何想法吗?

4

2 回答 2

0

您是遇到异常还是只是忽略了代码片段?如果没有例外,请确保“value”中存储的字符串是正确的,这可能是一个小问题,比如区分大小写。希望。

于 2012-08-23T00:19:28.050 回答
0
String uri = "android.resource://dr.droid/" + R.raw.fracture;
videoView1.setVideoURI(Uri.parse(uri));
于 2012-08-23T01:17:28.870 回答