音量控制键控制的音频流(setVolumeControlStream)描述
程序员文章站
2023-12-02 18:44:40
当开发多媒体应用或者游戏应用的时候,需要使用音量控制键来设置程序的音量大小。在android系统中有多中音频流,通过activity中的函数 setvolumecontro...
当开发多媒体应用或者游戏应用的时候,需要使用音量控制键来设置程序的音量大小。在android系统中有多中音频流,通过activity中的函数 setvolumecontrolstream(int streamtype)可以设置该activity中音量控制键控制的音频流,一般在oncreate函数中设置。
android中有如下几种音频流:
•audiomanager.stream_music /** the audio stream for music playback */
•audiomanager.stream_ring /** the audio stream for the phone ring */
•audiomanager.stream_alarm /** the audio stream for alarms */
•audiomanager.stream_notification /** the audio stream for notifications */
•audiomanager.stream_system /** the audio stream for system sounds */
•audiomanager.stream_voicecall /** the audio stream for phone calls */
setvolumecontrolstream函数描述:
void android.app.activity .setvolumecontrolstream(int streamtype)
suggests an audio stream whose volume should be changed by the hardware volume controls.
the suggested audio stream will be tied to the window of this activity. if the activity is switched, the stream set here is no longer the suggested stream. the client does not need to save and restore the old suggested stream value in onpause and onresume.
parameters:
streamtype the type of the audio stream whose volume should be changed by the hardware volume controls. it is not guaranteed that the hardware volume controls will always change this stream's volume (for example, if a call is in progress, its stream's volume may be changed instead). to reset back to the default, use audiomanager.use_default_stream_type .
android中有如下几种音频流:
•audiomanager.stream_music /** the audio stream for music playback */
•audiomanager.stream_ring /** the audio stream for the phone ring */
•audiomanager.stream_alarm /** the audio stream for alarms */
•audiomanager.stream_notification /** the audio stream for notifications */
•audiomanager.stream_system /** the audio stream for system sounds */
•audiomanager.stream_voicecall /** the audio stream for phone calls */
setvolumecontrolstream函数描述:
void android.app.activity .setvolumecontrolstream(int streamtype)
suggests an audio stream whose volume should be changed by the hardware volume controls.
the suggested audio stream will be tied to the window of this activity. if the activity is switched, the stream set here is no longer the suggested stream. the client does not need to save and restore the old suggested stream value in onpause and onresume.
parameters:
streamtype the type of the audio stream whose volume should be changed by the hardware volume controls. it is not guaranteed that the hardware volume controls will always change this stream's volume (for example, if a call is in progress, its stream's volume may be changed instead). to reset back to the default, use audiomanager.use_default_stream_type .