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


Java OnCompletionListener类代码示例

本文整理汇总了Java中android.media.MediaPlayer.OnCompletionListener的典型用法代码示例。如果您正苦于以下问题:Java OnCompletionListener类的具体用法?Java OnCompletionListener怎么用?Java OnCompletionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OnCompletionListener类属于android.media.MediaPlayer包,在下文中一共展示了OnCompletionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: soundShake

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
private void soundShake() {
    try {
        this.mPlayer = MediaPlayer.create(RedPacketSdkManager.getInstance().getApplicationContext(), R.raw.shake_sound);
        if (this.mPlayer != null) {
            this.mPlayer.start();
            this.mPlayer.setOnCompletionListener(new OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    RedPacketDialog.this.mPlayer.release();
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (this.mPlayer != null) {
            this.mPlayer.release();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:19,代码来源:RedPacketDialog.java

示例2: playSoundFile

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
@ReactMethod
public void playSoundFile(String name, String type) throws IOException {
  if (this.mediaPlayer == null) {
    int soundResID = getReactApplicationContext().getResources().getIdentifier(name, "raw", getReactApplicationContext().getPackageName());
    this.mediaPlayer = MediaPlayer.create(getCurrentActivity(), soundResID);
    this.mediaPlayer.setOnCompletionListener(
      new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer arg0) {
          WritableMap params = Arguments.createMap();
          params.putBoolean("success", true);
          sendEvent(getReactApplicationContext(), "FinishedPlaying", params);
        }
    });
  } else {
    Uri uri = Uri.parse("android.resource://" + getReactApplicationContext().getPackageName() + "/raw/" + name);
    this.mediaPlayer.reset();
    this.mediaPlayer.setDataSource(getCurrentActivity(), uri);
    this.mediaPlayer.prepare();
  }
  this.mediaPlayer.start();
}
 
开发者ID:johnsonsu,项目名称:react-native-sound-player,代码行数:23,代码来源:RNSoundPlayerModule.java

示例3: chimeSound

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
public static void chimeSound() {
  ((Activity) MainMenu.getAppContext()).runOnUiThread(new Runnable() {
    public void run() {
      final MediaPlayer mp1 = MediaPlayer.create(MainMenu.getAppContext(), R.raw.chime);
      mp1.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
          mp1.release();
        }

      });
      mp1.start();
    }
  });
}
 
开发者ID:UshalNaidoo,项目名称:Android-Bubble-Game,代码行数:17,代码来源:GamePanel.java

示例4: popSound

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
public static void popSound() {
  ((Activity) MainMenu.getAppContext()).runOnUiThread(new Runnable() {
    public void run() {
      final MediaPlayer mp2 = MediaPlayer.create(MainMenu.getAppContext(), R.raw.bub_pop);
      mp2.setVolume(0,1);
      mp2.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
          mp2.release();
        }
      });
      mp2.start();

    }
  });
}
 
开发者ID:UshalNaidoo,项目名称:Android-Bubble-Game,代码行数:17,代码来源:GamePanel.java

示例5: initViews

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
protected void initViews() {
    this.mVideoView = (ExVideoView) findViewById(R.id.video);
    this.mHeaderView = findViewById(R.id.header);
    this.mBtnBack = findViewById(R.id.btn_back);
    this.mVideoView.setExpandState(true);
    this.mVideoView.setStatus(2);
    this.mVideoView.setContinueVideo(this.mUri);
    this.mVideoView.getVideoView().setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {
            SportPlayActivity.this.setResult(-1);
            SportPlayActivity.this.finish();
        }
    });
    this.mVideoView.getControllerView().addBindView(this.mHeaderView);
    this.mBtnBack.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            SportPlayActivity.this.onBackPressed();
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:SportPlayActivity.java

示例6: initPlayer

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
public static void initPlayer(VideoView videoView, OnPreparedListener onPreparedListener,
                              OnCompletionListener onCompletionListener, OnErrorListener
                                      onErrorListener) {
    if (onPreparedListener != null) {
        videoView.setOnPreparedListener(onPreparedListener);
    }
    if (onCompletionListener != null) {
        videoView.setOnCompletionListener(onCompletionListener);
    }
    if (onErrorListener != null) {
        videoView.setOnErrorListener(onErrorListener);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:VideoPlayerManager.java

示例7: initVideoData

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
private void initVideoData() {
    if (this.mentionIndex >= this.totalMetionCount) {
        lessonFinish();
        return;
    }
    this.currentMention = (Mention) this.mentionList.get(this.mentionIndex);
    this.videoPath = this.videoDownloadHelper.getVideoName(this.ctx, this.currentMention.id);
    this.videoView.setVideoPath(this.videoPath);
    this.videoView.setOnErrorListener(new OnErrorListener() {
        public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
            VideoPlayActivity.this.onPlayError();
            return true;
        }
    });
    this.videoView.setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {
            if (VideoPlayActivity.this.currentMention.is_times && !VideoPlayActivity.this
                    .isMentionComplete() && VideoPlayActivity.this.isCounting) {
                VideoPlayActivity.this.handler.post(VideoPlayActivity.this.countDownRunnable);
                VideoPlayActivity.this.playCountNum = VideoPlayActivity.this.playCountNum + 1;
            }
            VideoPlayActivity.this.videoView.seekTo(0);
            VideoPlayActivity.this.videoView.start();
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:VideoPlayActivity.java

示例8: setOnCompletionListener

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
/**
 *
 * <p>Title: setOnCompletionListener</p>
 * <p>Description: Set the playback end of speech monitoring,
 *    again will play the status is set to an initial state</p>
 *    @see com.youkes.vr.common.utils.MediaPlayTools#status
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_ERROR}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_PLAYING}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_PAUSE}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_STOP}
 */
private void setOnCompletionListener() {

	// 
	mediaPlayer.setOnCompletionListener(new OnCompletionListener() {

		@Override
		public void onCompletion(MediaPlayer mp) {
			LogUtil.d(TAG, "[MediaPlayTools - setOnCompletionListener] Play file[" + urlPath+ "] com");
			status = STATUS_STOP;

			if(mListener != null) {
				mListener.OnVoicePlayCompletion();
			}
		}
	});
}
 
开发者ID:zhangjingpu,项目名称:youkes_vr,代码行数:28,代码来源:MediaPlayTools2.java

示例9: setOnCompletionListener

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
/**
 *
 * <p>Title: setOnCompletionListener</p>
 * <p>Description: Set the playback end of speech monitoring,
 *    again will play the status is set to an initial state</p>
 *    @see com.youkes.vr.common.utils.MediaPlayTools#status
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_ERROR}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_PLAYING}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_PAUSE}
 *    {@link com.youkes.vr.common.utils.MediaPlayTools#STATUS_STOP}
 */
private void setOnCompletionListener() {

    //
    mediaPlayer.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            LogUtil.d(TAG, "[MediaPlayTools - setOnCompletionListener] Play file[" + urlPath+ "] com");
            status = STATUS_STOP;

            if(mListener != null) {
                mListener.OnVoicePlayCompletion();
            }
        }
    });
}
 
开发者ID:zhangjingpu,项目名称:youkes_vr,代码行数:28,代码来源:MediaPlayToolsUtil.java

示例10: onTimeout

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
/**
 * Takes appropriate action to notify user and dismiss activity on timeout.
 */
private void onTimeout() {
    Log.d(TAG, "Media Button Selector: Timed out waiting for user interaction, finishing activity");
    final MediaPlayer timeoutPlayer = MediaPlayer.create(this, R.raw.dismiss);
    timeoutPlayer.start();
    // not having an on error listener results in on completion listener
    // being called anyway
    timeoutPlayer.setOnCompletionListener(new OnCompletionListener() {

        public void onCompletion(MediaPlayer mp) {
            timeoutPlayer.release();
        }
    });

    // If the user has set their preference not to confirm actions, we'll
    // just forward automatically to whoever was last selected. If no one is
    // selected, it just acts like finish anyway.
    if (preferences.getBoolean(Constants.CONFIRM_ACTION_PREF_KEY, true)) {
        finish();
    } else {
        select();
    }
}
 
开发者ID:harleensahni,项目名称:media-button-router,代码行数:26,代码来源:ReceiverSelector.java

示例11: playMusic

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
private void playMusic(String name) {
	try {
		if (mMediaPlayer.isPlaying()) {
			mMediaPlayer.stop();
		}
		System.out.println(name + "haha");
		mMediaPlayer.reset();
		mMediaPlayer.setDataSource(name);
		mMediaPlayer.prepare();
		mMediaPlayer.start();
		mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
			public void onCompletion(MediaPlayer mp) {

			}
		});

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:22,代码来源:RoomChatAdapter.java

示例12: playMusic

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
/**
 * ��������
 * 
 * @param name
 */
public static void playMusic(String name) {
	try {
		if (mMediaPlayer.isPlaying()) {
			mMediaPlayer.stop();
		}
		mMediaPlayer.reset();
		mMediaPlayer.setDataSource(name);

		mMediaPlayer.prepare();
		mMediaPlayer.start();
		mMediaPlayer.setVolume((float) 0.81, (float) 0.82);
		mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
			public void onCompletion(MediaPlayer mp) {

			}
		});

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:28,代码来源:CommonUtils.java

示例13: createErrorDialog

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
private static AlertDialog createErrorDialog(final Context context, final OnCompletionListener completionListener, final MediaPlayer mediaPlayer, final int errorMessage) {
    return new AlertDialog.Builder(context)
            .setMessage(errorMessage)
            .setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(final DialogInterface dialog, final int whichButton) {
                                /* If we get here, there is no onError listener, so
                                 * at least inform them that the video is over.
                                 */
                            if (completionListener != null) {
                                completionListener.onCompletion(mediaPlayer);
                            }
                        }
                    }
            )
            .setCancelable(false)
            .create();
}
 
开发者ID:eugenkiss,项目名称:chanobol,代码行数:19,代码来源:FensterVideoView.java

示例14: playAlarm

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
/**
 * 播放报警音乐
 * 
 * @param context
 */
private void playAlarm(Context context) {
	final AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
	final int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
	mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), AudioManager.FLAG_PLAY_SOUND);

	Logger.i(TAG, "播放报警音乐");
	MediaPlayer player = MediaPlayer.create(context, R.raw.alarm);
	player.setLooping(false);
	player.start();
	player.setOnCompletionListener(new OnCompletionListener() {

		@Override
		public void onCompletion(MediaPlayer mp) {
			mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, AudioManager.FLAG_PLAY_SOUND);
		}
	});
}
 
开发者ID:bingoogolapple,项目名称:Graduation-Design,代码行数:23,代码来源:TheftReceiver.java

示例15: createErrorDialog

import android.media.MediaPlayer.OnCompletionListener; //导入依赖的package包/类
private static AlertDialog createErrorDialog(final Context context, final OnCompletionListener completionListener, final MediaPlayer mediaPlayer, final int errorMessage) {
    return new AlertDialog.Builder(context)
            .setMessage(errorMessage)
            .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(final DialogInterface dialog, final int whichButton) {
                                /* If we get here, there is no onError listener, so
                                 * at least inform them that the video is over.
                                 */
                            if (completionListener != null) {
                                completionListener.onCompletion(mediaPlayer);
                            }
                        }
                    }
            )
            .setCancelable(false)
            .create();
}
 
开发者ID:malmstein,项目名称:fenster,代码行数:20,代码来源:FensterVideoView.java


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