本文整理汇总了Java中android.media.audiofx.AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION属性的典型用法代码示例。如果您正苦于以下问题:Java AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION属性的具体用法?Java AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION怎么用?Java AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.media.audiofx.AudioEffect
的用法示例。
在下文中一共展示了AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDataSource
/**
* @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
*/
void setDataSource(final String path) {
Logger.d(TAG, "setDataSourceImpl, path: " + path);
try {
mCurrentMediaPlayer.reset();
mCurrentMediaPlayer.setOnPreparedListener(this);
mCurrentMediaPlayer.setDataSource(path);
mCurrentMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mCurrentMediaPlayer.prepareAsync();
preparing = true;
mService.get().mIsSupposedToBePlaying = false;
} catch (final IOException e) {
e.printStackTrace();
}
mCurrentMediaPlayer.setOnCompletionListener(this);
mCurrentMediaPlayer.setOnErrorListener(this);
mCurrentMediaPlayer.setOnBufferingUpdateListener(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, mService.get().getPackageName());
mService.get().sendBroadcast(intent);
//return true;
resetBufferPercent();
mService.get().notifyChange(PLAYSTATE_CHANGED);
}
示例2: setDataSourceImpl
/**
* @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;
}
示例3: sendPlayingStatusChangedBroadcast
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);
}
示例4: setDataSourceImpl
/**
* @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(final MediaPlayer player, final String path) {
MusicPlaybackService service = mService.get();
if (service == null) {
return false;
}
try {
player.reset();
player.setOnPreparedListener(null);
if (path.startsWith("content://")) {
player.setDataSource(service, Uri.parse(path));
} else {
player.setDataSource(path);
}
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.prepare();
} catch (Exception e) {
Timber.w(e, "setDataSourceImpl");
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, service.getPackageName());
intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
service.sendBroadcast(intent);
return true;
}
示例5: applyAudioEffects
void applyAudioEffects() {
if (mAudioSessionId <= 0) {
removeAudioEffects();
return;
}
//apply audio effects to our new sessionId
final Intent audioEffectsIntent = new Intent(
AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mAudioSessionId);
audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mContext.getPackageName());
audioEffectsIntent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
mContext.sendBroadcast(audioEffectsIntent);
}
示例6: broadcastOpenIntent
private static void broadcastOpenIntent() {
final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, BuildConfig.APPLICATION_ID);
intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, Player.audioSessionId);
Player.theApplication.sendBroadcast(intent);
}
示例7: play
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);
}
}
示例8: play
/**
* Resumes or starts playback.
*
* @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);
}
}
示例9: onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == OVERLAY_REQ) {
if (Build.VERSION.SDK_INT >= M) {
if (Settings.canDrawOverlays(this)) {
Log.d("MainActivity", "Granted");
} else {
Extras.getInstance().setWidgetTrack(true);
Log.d("MainActivity", "Denied or Grant permission Manually");
}
}
}
if (requestCode == WRITESETTINGS) {
if (Build.VERSION.SDK_INT >= M) {
if (!Settings.System.canWrite(this)) {
Log.d("MainActivity", "Granted");
} else {
Extras.getInstance().setSettings(true);
Log.d("MainActivity", "Denied or Grant permission Manually");
}
}
}
if (requestCode == EQ) {
Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
if (intent.getAction() != null && Helper.isActivityPresent(MainActivity.this, intent)) {
if (musicXService == null) {
return;
}
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, musicXService.audioSession());
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, this.getPackageName());
intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
sendBroadcast(intent);
} else {
Log.d("MainActivity", "Error");
}
}
if (requestCode == NAV && resultCode == RESULT_OK) {
intent = data;
}
}
示例10: bindSystemEqualizer
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);
}