google源码中默认seek操作最小时间间隔为250ms,如果从开始seek到seek结束花费的时间小于等于250ms,则认为不是有效的seek操作,表现为seekbar上的进度块会回到拖动的开始位置继续播放。
代码文件:packages/apps/Music/src/com/android/music/MediaPlaybackActivity.java
private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() { public void onStartTrackingTouch(SeekBar bar) { mLastSeekEventTime = 0; mFromTouch = true; } public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) { if (!fromuser || (mService == null)) return; long now = SystemClock.elapsedRealtime(); if ((now - mLastSeekEventTime) > 250) { // 默认seek操作最小时间间隔为250ms mLastSeekEventTime = now; mPosOverride = mDuration * progress / 1000; try { mService.seek(mPosOverride); } catch (RemoteException ex) { } // trackball event, allow progress updates if (!mFromTouch) { refreshNow(); mPosOverride = -1; } } } public void onStopTrackingTouch(SeekBar bar) { mPosOverride = -1; mFromTouch = false; } };