本文整理匯總了Java中android.media.MediaPlayer.seekTo方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaPlayer.seekTo方法的具體用法?Java MediaPlayer.seekTo怎麽用?Java MediaPlayer.seekTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.seekTo方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playClick
import android.media.MediaPlayer; //導入方法依賴的package包/類
private void playClick(int keyCode) {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 0x20:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 0x0a:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
case 0x38:
if (prefs.getBoolean("pref_eight_enable", false)) {
// Play random "eight" sound
MediaPlayer mPlayer = mediaEight[rand.nextInt(mediaEight.length)];
mPlayer.seekTo(0);
mPlayer.start();
}
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
示例2: prepareMediaPlayerFromPoint
import android.media.MediaPlayer; //導入方法依賴的package包/類
private void prepareMediaPlayerFromPoint(int progress) {
//set mediaPlayer to start from middle of the audio file
mMediaPlayer = new MediaPlayer();
try {
mMediaPlayer.setDataSource(item.getFilePath());
mMediaPlayer.prepare();
mSeekBar.setMax(mMediaPlayer.getDuration());
mMediaPlayer.seekTo(progress);
mMediaPlayer.setOnCompletionListener(mp -> stopPlaying());
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
//keep screen on while playing audio
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
示例3: onCompletion
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.seekTo(0);
}
示例4: seekTo
import android.media.MediaPlayer; //導入方法依賴的package包/類
/**
* seek to position
*
* @param position
* @return
*/
public synchronized UDAudio seekTo(Integer position) {
if (position != null) {
final MediaPlayer player = getMediaPlayer();
if (player != null) {
try {
player.seekTo(position);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return this;
}
示例5: onPrepared
import android.media.MediaPlayer; //導入方法依賴的package包/類
private void onPrepared(MediaPlayer mp, int position) {
if(position > 0 && position < mp.getDuration()) {
mp.seekTo(position);
}
setStateInternal(STATE_PLAYING);
mp.start();
}
示例6: onCompletion
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.seekTo(0);
}
示例7: onCompletion
import android.media.MediaPlayer; //導入方法依賴的package包/類
@Override
public void onCompletion(MediaPlayer mp) {
// When the beep has finished playing, rewind to queue up another one.
mp.seekTo(0);
}
示例8: onCompletion
import android.media.MediaPlayer; //導入方法依賴的package包/類
@Override
public void onCompletion(MediaPlayer mp) {
// When the beep has finished playing, rewind to queue up another one.
mp.seekTo(0);
}
示例9: onCompletion
import android.media.MediaPlayer; //導入方法依賴的package包/類
@Override
public void onCompletion(MediaPlayer mp) {
// When the beep has finished playing, rewind to queue up another one.
mp.seekTo(0);
}