Android 暂停视频后,视频不会在videoView中更新,而seekbar会被拖到新位置

Android 暂停视频后,视频不会在videoView中更新,而seekbar会被拖到新位置,android,android-videoview,seekbar,Android,Android Videoview,Seekbar,这是我正在开发的应用程序的示例代码 这是我的班级档案 public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); sb = (SeekBar)findViewById(R.id.control_seekbar); mVideoView1 = (VideoView) findViewById(R.id.surface_vi

这是我正在开发的应用程序的示例代码

这是我的班级档案

public void onCreate(Bundle icicle) 
   {
     super.onCreate(icicle);
     setContentView(R.layout.main);

     sb = (SeekBar)findViewById(R.id.control_seekbar);

     mVideoView1 = (VideoView) findViewById(R.id.surface_view1);
     mVideoView1.setVideoPath("android.resource://" + getPackageName() +"/"+R.raw.play);              
     mVideoView1.pause();

     mVideoView2 = (VideoView) findViewById(R.id.surface_view2);
     mVideoView2.setVideoPath("android.resource://" + getPackageName() +"/"+R.raw.play);              
     mVideoView2.pause();

     v1 = mVideoView1.getDuration();
     v2 = mVideoView2.getDuration();

     mVideoView1.setOnPreparedListener(new OnPreparedListener() 
     {
        @Override
        public void onPrepared(MediaPlayer arg0) 
        {
            sb.setMax(mVideoView1.getDuration());
            sb.postDelayed(onEverySecond, 60);
        }
     });



     sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() 
     {  
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) 
        {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) 
        {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) 
        {
            mVideoView1.seekTo(progress);
            mVideoView2.seekTo(progress);
        }
    });

   }

   private Runnable onEverySecond=new Runnable() 
   {
        @Override
        public void run() {

            if(sb != null) {
                sb.setProgress(mVideoView1.getCurrentPosition());
            }

            if(mVideoView1.isPlaying()) 
            {
                sb.postDelayed(onEverySecond, 1000);
            }

        }
    };
这是我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <LinearLayout 
       android:id="@+id/video_ll"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_above="@+id/control_btn_ll"
       android:orientation="horizontal">

        <VideoView
            android:id="@+id/surface_view1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:overScrollMode="always"/>

        <VideoView
            android:id="@+id/surface_view2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:overScrollMode="always"/>

   </LinearLayout>

   <LinearLayout 
       android:id="@+id/control_btn_ll"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerHorizontal="true"
       android:layout_alignParentBottom="true">

       <SeekBar
           android:id="@+id/control_seekbar"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:max="100"
           android:minHeight="1dp"
           android:minWidth="250dp" />

   </LinearLayout>

</RelativeLayout>

我有两个视频,必须在拖动seekbar时同时更新。 视频应该暂停,我希望视频视图更新到帧,我在seekbar中拖动

它在播放视频时工作正常,但在暂停时不更新


先谢谢你

如果搜索暂停,Androids视频不会在搜索后更新帧。您必须让视频播放几毫秒,然后再次暂停。这是唯一可行的方法。

我甚至尝试在100毫秒后暂停视频。但我只能得到与暂停时相同的特定帧,即使我将seekbar拖到新位置。尝试添加OnSeekCompleteListener,并在完成搜索后让视频运行。让它播放大约200毫秒并暂停。但在SeekCompleteListener无法用videoView实现。啊,是的,很抱歉,我忘了提到我使用了支持此功能的MediaPlayer。正因为如此,我从纯视频视图改为MP。