本文整理汇总了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);
}