當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。