当前位置: 首页>>代码示例>>Java>>正文


Java MediaPlayer.seekTo方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:rollforbugs,项目名称:lokey,代码行数:26,代码来源:IME.java

示例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);
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:20,代码来源:PlaybackFragment.java

示例3: onCompletion

import android.media.MediaPlayer; //导入方法依赖的package包/类
public void onCompletion(MediaPlayer mediaPlayer) {
    mediaPlayer.seekTo(0);
}
 
开发者ID:RuanXiaoHui,项目名称:ZxingScan,代码行数:4,代码来源:CaptureFragment.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:20,代码来源:UDAudio.java

示例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();
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:8,代码来源:MediaHelper.java

示例6: onCompletion

import android.media.MediaPlayer; //导入方法依赖的package包/类
public void onCompletion(MediaPlayer mediaPlayer) {
	mediaPlayer.seekTo(0);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:CaptureActivity.java

示例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);
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:6,代码来源:BeepManager.java

示例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);
}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:6,代码来源:BeepManager.java

示例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);
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:6,代码来源:BeepManager.java


注:本文中的android.media.MediaPlayer.seekTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。