I tried playing a wav file using mediaplayer and i can clearly hear it but when i tried playing a video, no sound heard.
code :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_layout);
videoView = (VideoView) findViewById(R.id.vdo);
path = "android.resource://" +getPackageName() + "/raw/" +R.raw.video;
videoView.setVideoURI(Uri.parse(path));
videoView.setMediaController(new MediaController(this));
}
public void doPlayVid(View v){
Log.d("path",path);
switch(v.getId()) {
case R.id.btn_video_play:
videoView.start();
break;
}
}
Thanks :)
You have to set volume of media player. You can do by first setting listener videoView.setOnPreparedListener(preparedListener);
and then you can in method public void onPrepared(MediaPlayer m) {
of preparedListener
set desired volume m.setVolume(0f, 0f);
Example with inline listener:
videoview.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setVolume(0, 0);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.