3

在我的主要活动中,当用户单击“跳过”按钮时,我正在 VideoView 上播放视频:-

 skip_button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                vv.stopPlayback();
                vv = null;
                video_layout.setVisibility(View.GONE);
                main_layout.setVisibility(View.VISIBLE);    
            }
        });

下一个 Activity 将打开到现在,这工作正常,但是当回到具有 VideoView 的上一个 Activity 时,它需要很长时间才能返回。

这是控制台消息显示:

04-23 16:09:29.091: I/MediaPlayer(3152): MediaPlayer 

04-23 16:09:29.091: I/MediaPlayer(3152): MediaPlayer setDataSource(context, uri,headers)

04-23 16:09:29.201: I/MediaPlayer(3152): MediaPlayer setDisplay()

04-23 16:09:29.311: I/MediaPlayer(3152): MediaPlayer handleMessage what=5

04-23 16:09:29.311: I/MediaPlayer(3152): MediaPlayer handleMessage what=1

04-23 16:09:29.311: D/MediaPlayer(3152): getMetadata
4

1 回答 1

4

你有没有在活动的oncreate中初始化它-

final VideoView myVideoView = (VideoView)findViewById(R.id.videoView1);
            myVideoView.setVideoPath("/sdcard/demovideo.mp4");
            MediaController controller=new MediaController(this);
            myVideoView.setMediaController(controller);
            myVideoView.requestFocus();
于 2013-04-23T13:07:49.667 回答