VideoView 不会在其他 activity 上播放

VideoView won't play on a different activity

我有这个按钮可以在另一个 activity 上播放视频,或者在 Main2Activity 中特定。问题是当我点击按钮时视频无法播放。一切正常,唯一的问题是当我点击那个按钮时。

主要活动:

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

            resultvideo.setVideoURI(videoUri);
            mediacontroller.setAnchorView(resultvideo);
            resultvideo.pause();

        }
        buttonPlay = (Button) findViewById(R.id.buttonPlay);
        {
            buttonPlay.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mediacontroller.show();
                    mediacontroller.setAnchorView(resultvideo);
                    resultvideo.start();
                }
            });
        }

        buttonFullScreen = (Button) findViewById(R.id.buttonFullScreen);
        {
            buttonFullScreen.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                    intent.putExtra("VIDEO_URI", videoUri.toString());
                    startActivity(intent);
                }
            });
        }
    }

Main2Activity:

public class Main2Activity extends Activity {

    Button buttonPlay;
    Button buttonFullScreen;
    static final int REQUEST_VIDEO_CAPTURE = 1;
    VideoView resultvideo;
    MediaController mediacontroller;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String uri = getIntent().getStringExtra("VIDEO_URI");
        Uri videoUri = Uri.parse(uri);

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

        setContentView(R.layout.activity_main2);

        resultvideo = (VideoView)findViewById(R.id.videoView2);

        resultvideo.start();

    }
}

您需要添加

resultvideo.setVideoURI(videoUri);

在您为结果视频添加草签后。