国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Audio系列之靜音控制

2019-11-08 00:15:35
字體:
來源:轉載
供稿:網友

之前是使用靜音操作計數的方式的,就是只有靜音計數為0時才會取消靜音.每個i進程可以設一次靜音.在當進程死亡時,會自動取消靜音.當然靜音也會發同樣的廣播,只是音量為0的廣播.

但是后面就是一個AudioService#VolumeState#mIsMuted成員保存是否靜音的.而不用基數,就是每個應用都可以控制靜音和不靜音.

 /**     * Mute or unmute an audio stream.     * <p>     * This method should only be used by applications that replace the     * platform-wide management of audio settings or the main telephony     * application.     * <p>     * This method has no effect if the device implements a fixed volume policy     * as indicated by {@link #isVolumeFixed()}.     * <p>     * This method was dePRecated in API level 22. Prior to API level 22 this     * method had significantly different behavior and should be used carefully.     * The following applies only to pre-22 platforms:     * <ul>     * <li>The mute command is protected against client process death: if a     * process with an active mute request on a stream dies, this stream will be     * unmuted automatically.</li>     * <li>The mute requests for a given stream are cumulative: the AudioManager     * can receive several mute requests from one or more clients and the stream     * will be unmuted only when the same number of unmute requests are     * received.</li>     * <li>For a better user experience, applications MUST unmute a muted stream     * in onPause() and mute is again in onResume() if appropriate.</li>     * </ul>     *     * @param streamType The stream to be muted/unmuted.     * @param state The required mute state: true for mute ON, false for mute     *            OFF     * @see #isVolumeFixed()     * @deprecated Use {@link #adjustStreamVolume(int, int, int)} with     *             {@link #ADJUST_MUTE} or {@link #ADJUST_UNMUTE} instead.     */    @Deprecated    public void setStreamMute(int streamType, boolean state)可以看到上面的提示這個方法已經被淘汰在,這個方法可以用,但好像之可以讓用戶應用用于自己應用的控制,代替整個平臺范圍的音量設置.當設備實現了一個fixed volume policy時,這個方法會失效....用adjuststreamVolume(int, int, int)代替這個方法.就是說不用計數了.
/**     * Adjusts the volume of a particular stream by one step in a direction.     * <p>     * This method should only be used by applications that replace the platform-wide     * management of audio settings or the main telephony application.     *     * @param streamType The stream type to adjust. One of {@link #STREAM_VOICE_CALL},     * {@link #STREAM_SYSTEM}, {@link #STREAM_RING}, {@link #STREAM_MUSIC} or     * {@link #STREAM_ALARM}     * @param direction The direction to adjust the volume. One of     *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or     *            {@link #ADJUST_SAME}.     * @param flags One or more flags.     * @see #setStreamVolume(int, int, int)     * @see #adjustVolume(int, int)     */    public void adjustStreamVolume(int streamType, int direction, int flags) {        IAudioService service = getService();        try {            service.adjustStreamVolume(streamType, direction, flags,                    getContext().getOpPackageName());        } catch (RemoteException e) {            Log.e(TAG, "Dead object in adjustStreamVolume", e);        }    }這個方法就是一下一下調音量的


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 杭锦后旗| 车险| 贡嘎县| 克什克腾旗| 镇原县| 武山县| 赣榆县| 米脂县| 涿鹿县| 双辽市| 宾阳县| 蓝田县| 麻江县| 澄城县| 山东省| 林甸县| 鸡泽县| 西昌市| 民县| 平乡县| 太保市| 余庆县| 内黄县| 永胜县| 介休市| 新巴尔虎左旗| 潜山县| 海原县| 内丘县| 布尔津县| 三河市| 保定市| 弥勒县| 什邡市| 久治县| 德江县| 施秉县| 淳化县| 西安市| 甘肃省| 乐山市|