Java Code Examples for android.media.audiofx.AudioEffect#ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION
The following examples show how to use
android.media.audiofx.AudioEffect#ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiPlayer.java From Music-Player with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 2
Source File: MultiPlayer.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 3
Source File: MultiPlayer.java From Orin with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 4
Source File: MultiPlayer.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 5
Source File: MultiPlayer.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 6
Source File: MultiPlayer.java From Phonograph with GNU General Public License v3.0 | 5 votes |
/** * @param player The {@link MediaPlayer} to use * @param path The path of the file, or the http/rtsp URL of the stream * you want to play * @return True if the <code>player</code> has been prepared and is * ready to play, false otherwise */ private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { if (context == null) { return false; } try { player.reset(); player.setOnPreparedListener(null); if (path.startsWith("content://")) { player.setDataSource(context, Uri.parse(path)); } else { player.setDataSource(path); } player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.prepare(); } catch (Exception e) { return false; } player.setOnCompletionListener(this); player.setOnErrorListener(this); 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, context.getPackageName()); intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC); context.sendBroadcast(intent); return true; }
Example 7
Source File: RadioPlaybackService.java From Sky31Radio with Apache License 2.0 | 5 votes |
private void sendPlayingStatusChangedBroadcast(boolean isPlaying){ if(isPlaying){ final Intent audioEffectIntent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); audioEffectIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, player.mediaPlayer.getAudioSessionId()); audioEffectIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(audioEffectIntent); } buildNotification(); Intent statusChangedIntent = new Intent(); statusChangedIntent.setAction(ACTION_PLAYING_STATUS_CHANGED); statusChangedIntent.putExtra(RadioPlaybackService.KEY_IS_PLAYING, isPlaying); sendBroadcast(statusChangedIntent); }
Example 8
Source File: MusicService.java From Muzesto with GNU General Public License v3.0 | 4 votes |
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())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) 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(); notifyChange(META_CHANGED); } else if (mPlaylist.size() <= 0) { setShuffleMode(SHUFFLE_AUTO); } }
Example 9
Source File: EqualizedExoPlayer.java From Jockey with Apache License 2.0 | 4 votes |
private void bindSystemEqualizer(int audioSessionId) { Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mContext.getPackageName()); mContext.sendBroadcast(intent); }