Android Sound focus----from music back to luncher adjust the volume to show the volume of music

Source: Internet
Author: User
Tags dtmf tones

Types of sounds are: defined in the Audiosystem.java file

/* The default audio stream */public static final int stream_default = -1;/* the audio stream for phone calls */public STA Tic Final int stream_voice_call = 0;/* The audio STREAM for system sounds */public static final int stream_system = 1;/* T He audio stream for the phone ring and message alerts */public static final int stream_ring = 2;/* The audio stream for Mu SIC playback */public static final int stream_music = 3;/* The audio STREAM for alarms */public static final int Stream_al ARM = 4;/* The audio stream for notifications */public static final int stream_notification = 5;/* @hide the audio stream For phone calls when connected on Bluetooth */public static final int stream_bluetooth_sco = 6;/* @hide the audio STREAM F or enforced system sounds in certain countries (e.g camera in Japan) */public static final int stream_system_enforced = 7; /* @hide the audio stream for DTMF tones */public static final int STREAM_DTMF = 8;/* @hide The audio stream for text to s Peech (TTS) */public STATic Final int stream_tts = 9; 
Normally in the audio and video interface to adjust the volume of the stream is Stream_music, back to luncher adjust is stream_voice_call, but this switch a little delay streamoverride.sdelayms, resulting in the exit tone, After the video interface is adjusted immediately, the change is still the size of the Stream_music:

You can modify the/frameworks/base/media/java/android/media/audioservice.java file

 /** * For code clarity for Getactivestreamtype (int.) * @param Delay_ms max time since last Stream_music activity T o Consider * @return true if Stream_music is active in streams handled by Audioflinger now or * in the last "D     Elay_ms "Ms. */Private Boolean isafmusicactiverecently (int delay_ms) {return audiosystem.isstreamactive (AUDIOSYSTEM.STREAM_ MUSIC, Delay_ms) | |    Audiosystem.isstreamactiveremotely (Audiosystem.stream_music, Delay_ms); } private int Getactivestreamtype (int suggestedstreamtype) {switch (mplatformtype) {case Platform_voice                        : if (isincommunication ()) {if (Audiosystem.getforceuse (audiosystem.for_communication)) = = Audiosystem.force_bt_sco) {//LOG.V (TAG, "getactivestreamtype:forcing Stream_blueto                    Oth_sco ... ");                return Audiosystem.stream_bluetooth_sco; } else {//LOG.V (TAG, "getactiveStreamtype:forcing stream_voice_call ... ");                return audiosystem.stream_voice_call; }} else if (Suggestedstreamtype = = Audiomanager.use_default_stream_type) {if (isafmusicactiver ecently (streamoverride.sdelayms)) {if (Debug_vol) log.v (TAG, "getactivestreamty                    Pe:forcing stream_music STREAM Active ");                    return audiosystem.stream_music; } else {if (Debug_vol) log.v (TAG, "getactivestreamtype:forcing STREAM_                        RING b/c default ");                return audiosystem.stream_ring; }} else if (isafmusicactiverecently (0)) {if (Debug_vol) log.v (TAG, "getacti                Vestreamtype:forcing stream_music STREAM Active ");            return audiosystem.stream_music;        } break; Case Platform_television:if (SuggestedstreaMtype = = Audiomanager.use_default_stream_type) {//TV always defaults to Stream_music            return audiosystem.stream_music;        } break;                        Default:if (Isincommunication ()) {if (Audiosystem.getforceuse (audiosystem.for_communication) = = Audiosystem.force_bt_sco) {if (Debug_vol) log.v (TAG, "Getactivestreamtype:fo                    Rcing Stream_bluetooth_sco ");                return Audiosystem.stream_bluetooth_sco;                    } else {if (Debug_vol) log.v (TAG, "getactivestreamtype:forcing stream_voice_call");                return audiosystem.stream_voice_call; }} else if (Audiosystem.isstreamactive (Audiosystem.stream_notification, Streamoverride.sdel                    ayms) | |                Audiosystem.isstreamactive (audiosystem.stream_ring, streamoverride.sdelayms)) { if (DEbug_vol) log.v (TAG, "getactivestreamtype:forcing stream_notification");            return audiosystem.stream_notification; } else if (Suggestedstreamtype = = Audiomanager.use_default_stream_type) {if (isafmusicactiverecently (Strea                    moverride.sdelayms) {if (Debug_vol) log.v (TAG, "getactivestreamtype:forcing stream_music");                return audiosystem.stream_music; } else {if (Debug_vol) log.v (TAG, "getactivestreamtype:using Stream_notifi                    cation as default ");                return audiosystem.stream_notification;        }} break;         } if (Debug_vol) log.v (TAG, "getactivestreamtype:returning suggested type" + Suggestedstreamtype);    return suggestedstreamtype; }
Change isafmusicactiverecently (streamoverride.sdelayms) to: isafmusicactiverecently (0) or a small value.


Android Sound focus----from music back to luncher adjust the volume to show the volume of music

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.