0

I have 4 .mp4 videos that I need to play in an android app. I managed to play 1 video, but the other 3 won't play. I think video size is the issue. The video that I managed to play has a size of 1.4mb and the other 3 have a size of 6mb, 2.2mb, 3.8mb.

Here's my code for playing them.

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();
                        }
                }
            }

    }

The burn video is the one that I managed to play but the other 3, no luck! Any ideas?

Luke Villanueva
  • 2,030
  • 8
  • 44
  • 94

2 Answers2

0

Are you getting an exception or is it just ignoring the code snippet? If there are no exceptions make sure the string stored in "value" is correct, it could be a minor problem like being case-sensitive. Hopefully.

Ushal Naidoo
  • 2,704
  • 1
  • 24
  • 37
  • No errors/exceptions. Just an alert upon clicking the button saying can't play this video. I doubt that it the problem is in the string value since it can recognize that a particular video is not able to play. – Luke Villanueva Aug 23 '12 at 00:24
  • Then it would probably be the video size. But a 6mb file shouldn't be too large. I will do some research and try to get back to you on this. – Ushal Naidoo Aug 23 '12 at 01:16
0
String uri = "android.resource://dr.droid/" + R.raw.fracture;
videoView1.setVideoURI(Uri.parse(uri));
tesla1984
  • 541
  • 2
  • 8
  • If this is the solution. Why do you think 1 video is playing while the other 3 won't? – Luke Villanueva Aug 23 '12 at 05:42
  • sorry, my mistake. i have check your code and it is right. And the size of video is not the problem. – tesla1984 Aug 23 '12 at 07:04
  • what do you think is the problem? i already did some compression to lessen the video size and still the other videos won't play. only the burn one. – Luke Villanueva Aug 23 '12 at 15:37
  • may be the format of the videos. see [link](http://stackoverflow.com/questions/8012494/sorry-this-video-cannot-be-played-streaming-mp4-to-android) for detail – tesla1984 Aug 24 '12 at 01:14