Search in sources :

Example 6 with AudioManager

use of android.media.AudioManager in project gdk-apidemo-sample by googleglass.

the class SliderActivity method onCreate.

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    // Ensure screen stays on during demo.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(new CardAdapter(createCards(this)));
    mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Plays sound.
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.playSoundEffect(Sounds.TAP);
            processSliderRequest(position);
        }
    });
    setContentView(mCardScroller);
    mSlider = Slider.from(mCardScroller);
}
Also used : AudioManager(android.media.AudioManager) CardScrollView(com.google.android.glass.widget.CardScrollView) AdapterView(android.widget.AdapterView) CardAdapter(com.google.android.glass.sample.apidemo.card.CardAdapter) CardScrollView(com.google.android.glass.widget.CardScrollView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 7 with AudioManager

use of android.media.AudioManager in project JieCaoVideoPlayer by lipangit.

the class JCVideoPlayer method prepareMediaPlayer.

public void prepareMediaPlayer() {
    JCVideoPlayerManager.completeAll();
    Log.d(TAG, "prepareMediaPlayer [" + this.hashCode() + "] ");
    initTextureView();
    addTextureView();
    AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.requestAudioFocus(onAudioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
    JCUtils.scanForActivity(getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    JCMediaManager.CURRENT_PLAYING_URL = url;
    JCMediaManager.CURRENT_PLING_LOOP = loop;
    JCMediaManager.MAP_HEADER_DATA = headData;
    setUiWitStateAndScreen(CURRENT_STATE_PREPARING);
    JCVideoPlayerManager.setFirstFloor(this);
}
Also used : AudioManager(android.media.AudioManager)

Example 8 with AudioManager

use of android.media.AudioManager in project JieCaoVideoPlayer by lipangit.

the class JCVideoPlayer method onCompletion.

public void onCompletion() {
    Log.i(TAG, "onCompletion " + " [" + this.hashCode() + "] ");
    //save position
    if (currentState == CURRENT_STATE_PLAYING || currentState == CURRENT_STATE_PAUSE) {
        int position = getCurrentPositionWhenPlaying();
        //            int duration = getDuration();
        JCUtils.saveProgress(getContext(), url, position);
    }
    cancelProgressTimer();
    setUiWitStateAndScreen(CURRENT_STATE_NORMAL);
    // 清理缓存变量
    textureViewContainer.removeView(JCMediaManager.textureView);
    JCMediaManager.instance().currentVideoWidth = 0;
    JCMediaManager.instance().currentVideoHeight = 0;
    AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
    JCUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    clearFullscreenLayout();
    JCUtils.getAppCompActivity(getContext()).setRequestedOrientation(NORMAL_ORIENTATION);
    JCMediaManager.textureView = null;
    JCMediaManager.savedSurfaceTexture = null;
}
Also used : AudioManager(android.media.AudioManager)

Example 9 with AudioManager

use of android.media.AudioManager in project PLDroidPlayer by pili-engineering.

the class PLMediaPlayerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_media_player);
    mLoadingView = findViewById(R.id.LoadingView);
    mSurfaceView = (SurfaceView) findViewById(R.id.SurfaceView);
    mSurfaceView.getHolder().addCallback(mCallback);
    mVideoPath = getIntent().getStringExtra("videoPath");
    mAVOptions = new AVOptions();
    int isLiveStreaming = getIntent().getIntExtra("liveStreaming", 1);
    // the unit of timeout is ms
    mAVOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
    mAVOptions.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
    mAVOptions.setInteger(AVOptions.KEY_PROBESIZE, 128 * 1024);
    // Some optimization with buffering mechanism when be set to 1
    mAVOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, isLiveStreaming);
    mIsLiveStreaming = isLiveStreaming == 1;
    if (mIsLiveStreaming) {
        mAVOptions.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
    }
    // 1 -> hw codec enable, 0 -> disable [recommended]
    int iCodec = getIntent().getIntExtra("mediaCodec", AVOptions.MEDIA_CODEC_SW_DECODE);
    mAVOptions.setInteger(AVOptions.KEY_MEDIACODEC, iCodec);
    // whether start play automatically after prepared, default value is 1
    mAVOptions.setInteger(AVOptions.KEY_START_ON_PREPARED, 0);
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
Also used : AudioManager(android.media.AudioManager) AVOptions(com.pili.pldroid.player.AVOptions)

Example 10 with AudioManager

use of android.media.AudioManager in project PLDroidPlayer by pili-engineering.

the class PLMediaPlayerActivity method onDestroy.

@Override
protected void onDestroy() {
    super.onDestroy();
    release();
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audioManager.abandonAudioFocus(null);
}
Also used : AudioManager(android.media.AudioManager)

Aggregations

AudioManager (android.media.AudioManager)159 MediaPlayer (android.media.MediaPlayer)50 AudioEffect (android.media.audiofx.AudioEffect)42 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 Context (android.content.Context)9 Intent (android.content.Intent)7 IOException (java.io.IOException)7 Cea708CaptionRenderer (android.media.Cea708CaptionRenderer)5 ClosedCaptionRenderer (android.media.ClosedCaptionRenderer)5 MediaFormat (android.media.MediaFormat)5 Ringtone (android.media.Ringtone)5 SubtitleController (android.media.SubtitleController)5 TtmlRenderer (android.media.TtmlRenderer)5 WebVttRenderer (android.media.WebVttRenderer)5 PowerManager (android.os.PowerManager)5 InputStream (java.io.InputStream)5 View (android.view.View)4 NotificationManager (android.app.NotificationManager)3 PendingIntent (android.app.PendingIntent)3