在videoview的某个位置启动方法

时间:2013-12-07 14:10:54

标签: android video android-videoview

有没有办法在视频视频中播放视频的特定位置?

只有在我脑海中出现的东西是:

while(ture)
{
    if(videoview.getCurrentPosition==Position)
    {
        //do something
    }
}

1 个答案:

答案 0 :(得分:1)

在很高的水平上,这几乎就是你最终会想到的。

从效率的角度来看,你的建议不会很好。这样的东西对设备的影响要小得多:

Runnable thePollingLogic=new Runnable() {
  public void run() {
    if (yourVideoView.getCurrentPosition()>=theMagicPosition) {
      // do something
    }

    yourVideoView.postDelayed(this, 1);
}

这将检查您的位置,然后不再运行~1毫秒。您需要做的就是在开始播放视频后拨打thePollingLogic.run(),然后在不再需要轮询循环时拨打yourVideoView.removeCallbacks(thePollingLogic)

相关问题