Search in sources :

Example 21 with AudioManager

use of android.media.AudioManager in project platform_frameworks_base by android.

the class VolumeControlAction method shouldUpdateAudioVolume.

private boolean shouldUpdateAudioVolume(boolean mute) {
    // Do nothing if in mute.
    if (mute) {
        return true;
    }
    // Update audio status if current volume position is edge of volume bar,
    // i.e max or min volume.
    AudioManager audioManager = tv().getService().getAudioManager();
    int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    if (mIsVolumeUp) {
        int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        return currentVolume == maxVolume;
    } else {
        return currentVolume == 0;
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 22 with AudioManager

use of android.media.AudioManager in project platform_frameworks_base by android.

the class HdmiControlService method setAudioStatus.

void setAudioStatus(boolean mute, int volume) {
    AudioManager audioManager = getAudioManager();
    boolean muted = audioManager.isStreamMute(AudioManager.STREAM_MUSIC);
    if (mute) {
        if (!muted) {
            audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
        }
    } else {
        if (muted) {
            audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
        }
        // FLAG_HDMI_SYSTEM_AUDIO_VOLUME prevents audio manager from announcing
        // volume change notification back to hdmi control service.
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_HDMI_SYSTEM_AUDIO_VOLUME);
    }
}
Also used : AudioManager(android.media.AudioManager)

Example 23 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 24 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 25 with AudioManager

use of android.media.AudioManager in project enroscar by stanfy.

the class StreamingPlaybackService method onCreate.

@Override
public void onCreate() {
    if (DEBUG) {
        Log.v(TAG, "Streaming service is being created");
    }
    super.onCreate();
    wifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    handler = new InternalHandler(this);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {
        audioHelper = new AudioFocusHelper(this);
    } else {
        audioHelper = new OldApiAudioFocusHelper(this);
    }
    final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    final int c100 = 100;
    volume = (int) ((float) volume / audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) * c100);
    if (DEBUG) {
        Log.d(TAG, "Volume: " + volume);
    }
}
Also used : AudioManager(android.media.AudioManager)

Aggregations

AudioManager (android.media.AudioManager)157 MediaPlayer (android.media.MediaPlayer)49 AudioEffect (android.media.audiofx.AudioEffect)42 LargeTest (android.test.suitebuilder.annotation.LargeTest)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 Context (android.content.Context)8 IOException (java.io.IOException)7 Intent (android.content.Intent)6 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 InputStream (java.io.InputStream)5 PowerManager (android.os.PowerManager)4 Vibrator (android.os.Vibrator)4 SurfaceHolder (android.view.SurfaceHolder)4 SurfaceView (android.view.SurfaceView)4