List of usage examples for android.media.audiofx AudioEffect EXTRA_AUDIO_SESSION
String EXTRA_AUDIO_SESSION
To view the source code for android.media.audiofx AudioEffect EXTRA_AUDIO_SESSION.
Click Source Link
From source file:com.koma.music.service.MusicService.java
/** * Resumes or starts playback./*www.j a v a 2 s . com*/ * * @param createNewNextTrack True if you want to figure out the next track, false * if you want to re-use the existing next track (used for going back) */ public void play(boolean createNewNextTrack) { int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); LogUtils.d(TAG, "Starting playback: audio focus request status = " + status); if (status != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { return; } final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mSession.setActive(true); if (createNewNextTrack) { setNextTrack(); } else { setNextTrack(mNextPlayPos); } if (mPlayer.isInitialized()) { final long duration = mPlayer.duration(); if (mRepeatMode != MusicServiceConstants.REPEAT_CURRENT && duration > 2000 && mPlayer.position() >= duration - 2000) { gotoNext(true); } mPlayer.start(); mPlayerHandler.removeMessages(MusicServiceConstants.FADEDOWN); mPlayerHandler.sendEmptyMessage(MusicServiceConstants.FADEUP); setIsSupposedToBePlaying(true, true); cancelShutdown(); updateNotification(); } else if (mPlaylist.size() <= 0) { setShuffleMode(MusicServiceConstants.SHUFFLE_AUTO); } }
From source file:com.koma.music.service.MusicService.java
/** * Temporarily pauses playback.// w w w . j a v a2 s . c o m */ public void pause() { if (mPlayerHandler == null) return; LogUtils.d(TAG, "Pausing playback"); synchronized (this) { if (mPlayerHandler != null) { mPlayerHandler.removeMessages(MusicServiceConstants.FADEUP); } if (mIsSupposedToBePlaying) { final Intent intent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); if (mPlayer != null) { mPlayer.pause(); } setIsSupposedToBePlaying(false, true); stopShakeDetector(false); } } }
From source file:singh.amandeep.musicplayer.MusicService.java
/** * Temporarily pauses playback./*w w w . ja va2 s .co m*/ */ public void pause() { if (D) Log.d(TAG, "Pausing playback"); synchronized (this) { mPlayerHandler.removeMessages(FADEUP); if (mIsSupposedToBePlaying) { final Intent intent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mPlayer.pause(); setIsSupposedToBePlaying(false, true); //stopShakeDetector(false); } } }
From source file:com.av.remusic.service.MediaService.java
public void play(boolean createNewNextTrack) { int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); if (D)//from w w w .j a va 2 s. co m Log.d(TAG, "Starting playback: audio focus request status = " + status); if (status != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { return; } final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mAudioManager.registerMediaButtonEventReceiver( new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSession.setActive(true); if (createNewNextTrack) { setNextTrack(); } else { setNextTrack(mNextPlayPos); } if (mPlayer.isTrackPrepared()) { final long duration = mPlayer.duration(); if (mRepeatMode != REPEAT_CURRENT && duration > 2000 && mPlayer.position() >= duration - 2000) { gotoNext(true); } } mPlayer.start(); mPlayerHandler.removeMessages(FADEDOWN); mPlayerHandler.sendEmptyMessage(FADEUP); setIsSupposedToBePlaying(true, true); cancelShutdown(); updateNotification(); notifyChange(META_CHANGED); }
From source file:com.cyanogenmod.eleven.MusicPlaybackService.java
/** * Resumes or starts playback./*from w w w . j av a 2 s . c o m*/ * * @param createNewNextTrack True if you want to figure out the next track, false * if you want to re-use the existing next track (used for going back) */ public void play(boolean createNewNextTrack) { int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); if (D) Log.d(TAG, "Starting playback: audio focus request status = " + status); if (status != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { return; } final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mAudioManager.registerMediaButtonEventReceiver( new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName())); mSession.setActive(true); if (createNewNextTrack) { setNextTrack(); } else { setNextTrack(mNextPlayPos); } if (mPlayer.isInitialized()) { final long duration = mPlayer.duration(); if (mRepeatMode != REPEAT_CURRENT && duration > 2000 && mPlayer.position() >= duration - 2000) { gotoNext(true); } mPlayer.start(); mPlayerHandler.removeMessages(FADEDOWN); mPlayerHandler.sendEmptyMessage(FADEUP); setIsSupposedToBePlaying(true, true); cancelShutdown(); updateNotification(); } else if (mPlaylist.size() <= 0) { setShuffleMode(SHUFFLE_AUTO); } }
From source file:com.av.remusic.service.MediaService.java
public void pause() { if (D)/*from w w w . j av a 2 s. c om*/ Log.d(TAG, "Pausing playback"); synchronized (this) { mPlayerHandler.removeMessages(FADEUP); if (mIsSupposedToBePlaying) { final Intent intent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mPlayer.pause(); setIsSupposedToBePlaying(false, true); notifyChange(META_CHANGED); } } }
From source file:com.cyanogenmod.eleven.MusicPlaybackService.java
/** * Temporarily pauses playback./* w ww . j a v a2 s. c om*/ */ public void pause() { if (D) Log.d(TAG, "Pausing playback"); synchronized (this) { mPlayerHandler.removeMessages(FADEUP); if (mIsSupposedToBePlaying) { final Intent intent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); mPlayer.pause(); setIsSupposedToBePlaying(false, true); stopShakeDetector(false); } } }