本文整理匯總了Java中android.media.MediaPlayer.OnCompletionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaPlayer.OnCompletionListener方法的具體用法?Java MediaPlayer.OnCompletionListener怎麽用?Java MediaPlayer.OnCompletionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.OnCompletionListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playLevelSound
import android.media.MediaPlayer; //導入方法依賴的package包/類
/**
* Play the given audio file
* @param soundFile
*/
public void playLevelSound(String soundFile, MediaPlayer.OnCompletionListener callback) {
Debug.d("Playing sound: "+soundFile);
if (!this.isStarted || !this.isRunning) {
Debug.d("Game hasn't started yet, not playing any sound");
return;
}
if (this.levelSounds.containsKey(soundFile)) {
Music sound = this.levelSounds.get(soundFile);
sound.setOnCompletionListener(callback);
sound.play();
} else {
Debug.d("No levelSounds: " + soundFile + "");
}
}
示例2: addInternalPathForPlaying
import android.media.MediaPlayer; //導入方法依賴的package包/類
private void addInternalPathForPlaying(String rawNameForPlay, MediaPlayer.OnCompletionListener onCompletionListener) {
int playRawIndex = alertTypes.indexOf(AlertType.TYPE_RAW);
final PlayAudioPresenter playAudioPresenter;
if(playRawIndex == -1) {
playAudioPresenter = new PlayAudioPresenter();
} else {
playAudioPresenter = (PlayAudioPresenter) activePresenters.get(playRawIndex);
}
playAudioPresenter.setInternalPathForPlay(rawNameForPlay);
playAudioPresenter.setCallBack(onCompletionListener);
if(playRawIndex == -1) {
activePresenters.add(playAudioPresenter);
alertTypes.add(AlertType.TYPE_RAW);
}
}
示例3: showMessage
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void showMessage(Message message, MessageBox position, final boolean showNextButton, final MediaPlayer.OnCompletionListener listener) {
String messageText = message.text;
String messageSound = message.sound;
this.messageBox.detachChildren();
this.nextButton.setVisible(false);
this.messageBox.attachChild(this.nextButton);
this.positionMessageBox(position);
this.displayText = new Text(this.messageBox.getWidth()/2+16, this.messageBox.getHeight()/2, GameFonts.introText(), messageText, messageText.length(), new TextOptions(HorizontalAlign.LEFT), PhoeniciaContext.vboManager);
this.displayText.setAutoWrapWidth(this.messageBox.getWidth() - 32);
this.displayText.setAutoWrap(AutoWrap.WORDS);
this.messageBox.setHeight(this.displayText.getHeight() + 64);
this.displayText.setPosition(this.messageBox.getWidth() / 2 + 16, this.messageBox.getHeight() - (this.displayText.getHeight() / 2));
this.messageBox.attachChild(this.displayText);
if (messageSound != null && messageSound.length() > 0) {
Debug.d("Playing tour message sound: '" + messageSound + "'");
this.messagePlaying = true;
this.game.playLevelSound(messageSound, new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
messagePlaying = false;
if (listener != null) {
listener.onCompletion(mp);
}
if (showNextButton) {
nextButton.setVisible(true);
}
}
});
}
}
示例4: setOnCompletionListener
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void setOnCompletionListener(MediaPlayer.OnCompletionListener l) {
mOnCompletionListener = l;
}
示例5: setOnCompletionListener
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void setOnCompletionListener(MediaPlayer.OnCompletionListener l) {
mOnCompletionListener = l;
if (mVideoView != null) {
mVideoView.setOnCompletionListener(l);
}
}
示例6: setCallBack
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void setCallBack(MediaPlayer.OnCompletionListener callBack) {
this.callBack = callBack;
}
示例7: setOnCompletionListener
import android.media.MediaPlayer; //導入方法依賴的package包/類
public void setOnCompletionListener(
final MediaPlayer.OnCompletionListener pOnCompletionListener) {
this.assertNotReleased();
this.mMediaPlayer.setOnCompletionListener(pOnCompletionListener);
}