Example usage for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME

List of usage examples for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME

Introduction

In this page you can find the example usage for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME.

Prototype

String EXTRA_PACKAGE_NAME

To view the source code for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME.

Click Source Link

Document

Contains the package name of the calling application.

Usage

From source file:com.rks.musicx.services.MusicXService.java

@Override
public void onDestroy() {
    super.onDestroy();
    Extras.getInstance().setwidgetPosition(100);
    audioWidget.cleanUp();//from w w  w .j av  a  2s  .c  om
    audioWidget = null;
    Equalizers.EndEq();
    BassBoosts.EndBass();
    Virtualizers.EndVirtual();
    Loud.EndLoudnessEnhancer();
    Reverb.EndReverb();
    receiverCleanup();
    Extras.getInstance().eqSwitch(false);
    audioManager.abandonAudioFocus(this);
    removeProgress();
    fastplay = false;
    isPlaying = false;
    paused = false;
    stopMediaplayer();
    if (!Extras.getInstance().hideLockscreen()) {
        if (mediaSessionLockscreen != null) {
            mediaSessionLockscreen.release();
            mediaSessionLockscreen = null;
        }
    }
    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    if (Helper.isActivityPresent(this, i)) {
        i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSession());
        i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, this.getPackageName());
        sendBroadcast(i);
    } else {
        Log.d(TAG, "no activity found");
    }
    if (!Extras.getInstance().hideNotify()) {
        removeNotification();
    }
}

From source file:com.example.chu.myvideodemo.MusicService.java

public void play(boolean createNewNextTrack) {
    int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN);

    if (D)/*from   w ww.  j  ava2s .  com*/
        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);
    }
}

From source file:com.devalladolid.musictoday.MusicService.java

public void pause() {
    if (D)// ww w.  j  a  va  2s. c  o  m
        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();
            notifyChange(META_CHANGED);
            setIsSupposedToBePlaying(false, true);
        }
    }
}

From source file:com.naman14.timber.musicplayer.MusicService.java

public void play(boolean createNewNextTrack) {
    int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN);

    if (D) {//from   ww  w. jav a  2s.c o  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.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);
    }
}

From source file:com.naman14.timber.musicplayer.MusicService.java

public void pause() {
    if (D) {/* w w w.  j  a va2  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();
            notifyChange(META_CHANGED);
            setIsSupposedToBePlaying(false, true);
        }
    }
}

From source file:com.bluros.music.MusicService.java

public void play(boolean createNewNextTrack) {
    int status = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN);

    if (D)/*from   www . j  av a2  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.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);
    }
}

From source file:com.bluros.music.MusicService.java

public void pause() {
    if (D)/*from   w  w w .ja  v a  2  s .  c o  m*/
        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();
            notifyChange(META_CHANGED);
            setIsSupposedToBePlaying(false, true);
            stopShakeDetector(false);
        }
    }
}

From source file:com.koma.music.service.MusicService.java

/**
 * Resumes or starts playback.//from  w  w  w .  ja  v a  2 s.  c om
 *
 * @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  .  jav  a 2 s  .c  om*/
 */
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. j a v  a 2s .  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);
        }
    }
}