tags:

views:

31

answers:

0

i want to display the video in thumbnail image but i try error will come for my coding please help me... what mistake i made for my code

package media.media;


import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
import android.net.Uri;
import android.os.Environment;
import android.database.Cursor;
import android.provider.MediaStore;
import android.util.Log;
public class VideoViewDemo 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.videoview);

            // Get the external storage state


//            String Sdcard_path=Environment.getExternalStorageDirectory().getAbsolutePath() + "/VideoThumbnails/";
            String Sdcard_path="/data/VideoThumbnails/";
            //String state = Environment.getExternalStorageState();
            System.out.println("path" + Sdcard_path);
/*
            // 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 an image to the view
              Log.i("Video Found",videoPath.toString());

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

        }
    }