During the recording operation, we hope to stop the music played by codoy and other backend players and resume playing after the recording is completed. You can use the following code:
/** @ Param bmute: If the value is true, background music is disabled. * // @ Targetapi (build. version_codes.froyo) public static Boolean muteaudiofocus (context, Boolean bmute) {If (context = NULL) {log. D ("android_lab", "context is null. "); Return false;} If (! Versionutils. isrfroyo () {// versions earlier than 2.1 do not support the following APIs: requestaudiofocus and abandonaudiofocuslog. D ("android_lab", "android 2.1 and below can not stop music"); Return false;} Boolean bool = false; audiomanager AM = (audiomanager) context. getsystemservice (context. audio_service); If (bmute) {int result = aM. requestaudiofocus (null, audiomanager. stream_music, audiomanager. audiofocus_gain_transient); bool = Result = audiomanager. audiofocus_request_granted;} else {int result = aM. abandonaudiofocus (null); bool = Result = audiomanager. audiofocus_request_granted;} log. D ("android_lab", "pausemusic bmute =" + bmute + "result =" + bool); Return bool ;}
This article is sodino all, reprint please note the Source: http://blog.csdn.net/sodino/article/details/10055659
Or not? You try to follow the public account sodino, And the blog will be pushed to you in the future.