Android(安卓)Mediaplayer设置静音和恢复声音
16lz
2021-12-04
在Android的Mediaplyer当中,想要设置静音,之后再设置恢复声音。
关闭声音:
public void CloseVolume(){ videoPlayer.setVolume(0, 0); }
开启声音:
public void OpenVolume(){ AudioManager audioManager=(AudioManager)getSystemService(Service.AUDIO_SERVICE); videoPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM); videoPlayer.setVolume(audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM), audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM)); videoPlayer.start(); }
主要的方法就在这里,之前的基本设置 这里就不写了,包括实例化videoPlayer,以及setDataSource,prepare等
更多相关文章
- Android(安卓)判断当前网络连接是否可用、打开设置网络界面
- Android(安卓)设置StatusBar的颜色
- windowSoftInputMode属性设置值
- windowSoftInputMode属性设置值
- 2010.12.29(2)——— android GridView
- android notification 的总结分析
- Android倒计时 Android仿京东倒计时 Android商城倒计时
- android webview 使用js加载json文件失败
- android中跳转系统自带的界面