录制的视频不会在viewVideo上显示

时间:2017-08-29 17:05:42

标签: java android

我只需要帮助我的代码,我正在使用Android Studio。一切正常,但录制的视频不会在我的布局上的viewVideo中显示。

以下是代码:

public class MainActivity extends AppCompatActivity {

    static final int REQUEST_VIDEO_CAPTURE = 1;
    VideoView resultvideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button click = (Button)findViewById(R.id.videorec);
        resultvideo = (VideoView)findViewById(R.id.videoView);
    }

    public void dispatchTakeVideoIntent(View v) {
        Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
            Uri videoUri = data.getData();
            resultvideo.setVideoURI(videoUri);
        }
    }
}

1 个答案:

答案 0 :(得分:1)

        Uri videoUri = data.getData();
        resultvideo.setVideoURI(videoUri);
       // start call missing  
      resultvideo.start();