在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等

更多相关文章

  1. Android(安卓)判断当前网络连接是否可用、打开设置网络界面
  2. Android(安卓)设置StatusBar的颜色
  3. windowSoftInputMode属性设置值
  4. windowSoftInputMode属性设置值
  5. 2010.12.29(2)——— android GridView
  6. android notification 的总结分析
  7. Android倒计时 Android仿京东倒计时 Android商城倒计时
  8. android webview 使用js加载json文件失败
  9. android中跳转系统自带的界面

随机推荐

  1. android SD卡热插拔监听
  2. Android: To Use AsyncQueryHandler
  3. android实现文件读写功能
  4. Android Socket连接
  5. Android(安卓)Activity 堆栈关系
  6. android自定义通知栏并通过广播实现监听
  7. android学习资料大全
  8. 【Android】【Other】FileProvider相关 F
  9. android配置gradle国内镜像
  10. 【Android】在android studio中使用asser