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


Java AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION属性代码示例

本文整理汇总了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);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:36,代码来源:MusicPlaybackService.java

示例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;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:33,代码来源:MultiPlayer.java

示例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);
}
 
开发者ID:linroid,项目名称:Sky31Radio,代码行数:15,代码来源:RadioPlaybackService.java

示例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;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:35,代码来源:MultiPlayer.java

示例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);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:13,代码来源:PlaybackService.java

示例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);
}
 
开发者ID:carlosrafaelgn,项目名称:FPlayAndroid,代码行数:7,代码来源:ExternalFx.java

示例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);
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:46,代码来源:MusicService.java

示例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);
    }
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:48,代码来源:MusicService.java

示例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;
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:41,代码来源:MainActivity.java

示例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);
}
 
开发者ID:marverenic,项目名称:Jockey,代码行数:6,代码来源:EqualizedExoPlayer.java


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