http://blog.csdn.net/spinchao/article/details/51439322
Android静音播放视频
使用videvocView来静音播放视频,像微信朋友圈小视频预览一样。
实现方法是给videoview注册一个setOnPreparedListener的监听,就绪后设置音量为0;代码如下:
try {
Uri uri =Uri.parse(“xxx”);
mVideoPlayer.setVideoURI(uri);
mVideoPlayer.requestFocus();
mVideoPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener({@Overridepublic void onPrepared(MediaPlayer mp) {
if (mp.isPlaying()) {
mp.stop();
mp.release();
mp = new MediaPlayer();
}
mp.setVolume(0f,0f);
mp.setLooping(false);
mp.start();
}
});
mVideoPlayer.setFocusable(false);
mVideoPlayer.start();
} catch (Exception e) {
e.printStackTrace();
}