开发者

Get thumbnail of the recorded video to show on next screen

开发者 https://www.devze.com 2023-03-10 02:06 出处:网络
I recorded a video(not using intent) and i want to get the thumbnail of that specific video (sdcard/myfolder/sample.mp4) to show on the next screen/activity oncreate.I i try to get thumbnail in next a

I recorded a video(not using intent) and i want to get the thumbnail of that specific video (sdcard/myfolder/sample.mp4) to show on the next screen/activity oncreate.I i try to get thumbnail in next activity, app crashes. If i dont try to get thumbnail and just pass the video path to videoView of the next activity, It goes to next screen and the video starts playing. I want to record video, show thumbnail of that video on next screen, when thumbnail is clicked it plays the video.

I tried these two ways in the activity after the recording:

    Intent i = getIntent();
    Bundle extras = i.getExtras();
    String filename 开发者_Go百科= extras.getString("playfile");

    Bitmap tmb = ThumbnailUtils.createVideoThumbnail(filename,
            MediaStore.Images.Thumbnails.MINI_KIND);
    imgview.setImageBitmap(tmb);

The app crashes.

when i try this:

   Intent i = getIntent();
    Bundle extras = i.getExtras();
    String filename = extras.getString("playfile");

    mc = new MediaController(this);
    mc.setMediaPlayer(videoView);
    videoView.setMediaController(mc);
    videoView.setVideoPath(filename);
    videoView.requestFocus();
    videoView.start();

App doesn't crash and plays video. Any help?


Ok, i figured why it was crashing. In my camera activity i didnt destroy the surface properly.

This fixed it:

public void surfaceDestroyed(SurfaceHolder holder) {
    camera.stopPreview();
    camera.lock();
    camera.release();
    camera = null;
    previewing = false;
}

Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消