Hi,

All I'm trying to do is play the first video retrieved from the
external SD card, which on my T-Mobile G2 turns out to be the sample
video for the phone.

Now I assumed that since it plays in the phones video player, that
it'd have no problems with playing in the VideoView in my test app.

How wrong...

All I get is the audio playing. I'm pretty sure the code is all fine.
After all it's pretty simple. All I can think is that maybe the phones
video player uses some native playback function which supports more
video formats?

Can anyone else explain this behaviour?

Android Framework team?

Code:

public class Video extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
 
WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.video);

        // Get the external storage state
        String state = Environment.getExternalStorageState();

        // Check if we can read it in
        if (Environment.MEDIA_MOUNTED.equals(state)==false&&
                Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)==false)
        {
                // We can't read from the memory card, so warn and return;
                Toast toast = Toast.makeText(this,
                                "The SD card is either missing or not in a 
readable
state.", Toast.LENGTH_LONG);
                toast.show();
                return;
        }

        // Get a cursor to the video files
        Cursor cc = this.getContentResolver().query(
                        MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        null, null, null, null);

        // Get the video column index
        int videoIDColumn =
cc.getColumnIndex(MediaStore.Video.VideoColumns._ID);

        // Iterate though the videos pointed to by the cursor
        if (cc.moveToFirst())
        {
                        int videoID = cc.getInt(videoIDColumn);
                        Uri videoPath =
Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,String.valueOf(videoID));

                        // Log and add a video to the view
                        Log.i("Video Found",videoPath.toString());

                        VideoView videoView =
(VideoView)findViewById(R.id.VideoTest);
                        videoView.setVideoURI(videoPath);
                        videoView.start();
        }
        else
        {
                Toast toast = Toast.makeText(this,
                                "Can't find a video to play.", 
Toast.LENGTH_LONG);
                toast.show();
        }
    }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to