Java Code Examples for android.media.MediaPlayer#getAudioSessionId()
The following examples show how to use
android.media.MediaPlayer#getAudioSessionId() .
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: VideoView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 2
Source File: VideoView.java From imsdk-android with MIT License | 5 votes |
@Override public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 3
Source File: MusicUtils.java From mobile-manager-tool with MIT License | 5 votes |
/** * @param media player from apollo service. */ public static void initEqualizer(MediaPlayer player, Context context){ releaseEqualizer(); int id = player.getAudioSessionId(); mEqualizer = new Equalizer(1,id); mBoost = new BassBoost(1, id); updateEqualizerSettings(context); }
Example 4
Source File: VideoView.java From twitter-kit-android with Apache License 2.0 | 5 votes |
private void openVideo() { if (mUri == null || mSurfaceHolder == null) { // not ready for playback just yet, will try again later return; } // we shouldn't clear the target state, because somebody might have // called start() previously release(false); try { mMediaPlayer = new MediaPlayer(); if (mAudioSession != 0) { mMediaPlayer.setAudioSessionId(mAudioSession); } else { mAudioSession = mMediaPlayer.getAudioSessionId(); } mMediaPlayer.setOnPreparedListener(mPreparedListener); mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mMediaPlayer.setOnCompletionListener(mCompletionListener); mMediaPlayer.setOnErrorListener(mErrorListener); mMediaPlayer.setOnInfoListener(mInfoListener); mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = 0; mMediaPlayer.setLooping(mLooping); mMediaPlayer.setDataSource(getContext(), mUri); mMediaPlayer.setDisplay(mSurfaceHolder); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); // we don't set the target state here either, but preserve the // target state that was there before. mCurrentState = STATE_PREPARING; attachMediaController(); } catch (Exception ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); } }
Example 5
Source File: AssetVideoView.java From ResearchStack with Apache License 2.0 | 5 votes |
@Override public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 6
Source File: MediaVideoViewOld.java From Slide with GNU General Public License v3.0 | 5 votes |
@Override public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 7
Source File: TextureVideoView.java From texturevideoview with Apache License 2.0 | 5 votes |
public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 8
Source File: VideoView.java From Android-VideoView with GNU General Public License v2.0 | 5 votes |
@Override public int getAudioSessionId() { if (mAudioSession == 0) { MediaPlayer foo = new MediaPlayer(); mAudioSession = foo.getAudioSessionId(); foo.release(); } return mAudioSession; }
Example 9
Source File: musicHandler.java From Android-Music-Player with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) public musicHandler(musicPlayer Gh) { mEvent = new Event("PLayer"); this.Gh = Gh; loadStartup(); mediaplayer = new MediaPlayer(); mediaplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { if(needPlay){ isPrepared = true; play(needId); }else{ isPrepared = true; if(needStop){ needStop = false; }else{ mediaplayer.start(); } mediaplayer.setOnCompletionListener(OC); mEvent.trigger(playerEvents.SONG_CHANGED); } } }); needStop = true; playByNumber(0); EQs = new EqlizerSettings(Gh.getBaseContext()); bass = new BassBoost(0, mediaplayer.getAudioSessionId()); bass.setEnabled(true); equlizer = new Equalizer(0, mediaplayer.getAudioSessionId()); equlizer.setEnabled(true); virtualizer = new Virtualizer(0, mediaplayer.getAudioSessionId()); virtualizer.setEnabled(true); if(android.os.Build.VERSION.SDK_INT >= 19){ loudness = new LoudnessEnhancer( mediaplayer.getAudioSessionId()); loudness.setEnabled(true); }else{ loudness = null; } setEQs(EQs.isOn); setBass(EQs.BASS); setTrable(EQs.TRABLE); setVoice(EQs.VOICE); setVirtualizer(EQs.VIRCHULIZER); setLoudnessEnhancer(EQs.LOUDNESS); mEvent.trigger(playerEvents.EQ_CHANGED); mEvent.trigger(playerEvents.PLAYER_COMPLETE); }
Example 10
Source File: UniversalVideoView.java From LLApp with Apache License 2.0 | 4 votes |
private void openVideo() { if (mUri == null || mSurfaceHolder == null) { // not ready for playback just yet, will try again later return; } AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); // we shouldn't clear the target state, because somebody might have // called start() previously release(false); try { mMediaPlayer = new MediaPlayer(); if (mAudioSession != 0) { mMediaPlayer.setAudioSessionId(mAudioSession); } else { mAudioSession = mMediaPlayer.getAudioSessionId(); } mMediaPlayer.setOnPreparedListener(mPreparedListener); mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mMediaPlayer.setOnCompletionListener(mCompletionListener); mMediaPlayer.setOnErrorListener(mErrorListener); mMediaPlayer.setOnInfoListener(mInfoListener); mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = 0; mMediaPlayer.setDataSource(mContext, mUri); mMediaPlayer.setDisplay(mSurfaceHolder); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); // we don't set the target state here either, but preserve the // target state that was there before. mCurrentState = STATE_PREPARING; attachMediaController(); } catch (IOException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); } }
Example 11
Source File: AssetVideoView.java From ResearchStack with Apache License 2.0 | 4 votes |
private void openVideo() { if (mFileDescriptor == null || mSurfaceHolder == null) { // not ready for playback just yet, will try again later return; } // we shouldn't clear the target state, because somebody might have // called start() previously release(false); AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); try { mMediaPlayer = new MediaPlayer(); if (mAudioSession != 0) { mMediaPlayer.setAudioSessionId(mAudioSession); } else { mAudioSession = mMediaPlayer.getAudioSessionId(); } mMediaPlayer.setOnPreparedListener(mPreparedListener); mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mMediaPlayer.setOnCompletionListener(mCompletionListener); mMediaPlayer.setOnErrorListener(mErrorListener); mMediaPlayer.setOnInfoListener(mInfoListener); mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = 0; mMediaPlayer.setDataSource(mFileDescriptor, mStartOffset, mLength); mMediaPlayer.setDisplay(mSurfaceHolder); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); // we don't set the target state here either, but preserve the // target state that was there before. mCurrentState = STATE_PREPARING; attachMediaController(); } catch (IOException | IllegalArgumentException ex) { Log.w(TAG, "Unable to open content: " + mFileDescriptor, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); return; } }