Firstly say that you can download the source code example below at the end of this post.
In order to create a volume control using SeekBar, we have to know the maximum volume and current volume. It can be retrieved using the method audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) and audioManager.getStreamVolume(AudioManager.STREAM_MUSIC). And we can change the volume when SeekBar changed, using the method audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume index, flags).
Firstly, modify main.xml to add a SeekBar as Volume Control.
Modify AndroidVideoPlayer to handle the SeekBar as Volume Control.
The source code for this example ---> HERE
In order to create a volume control using SeekBar, we have to know the maximum volume and current volume. It can be retrieved using the method audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) and audioManager.getStreamVolume(AudioManager.STREAM_MUSIC). And we can change the volume when SeekBar changed, using the method audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume index, flags).
Firstly, modify main.xml to add a SeekBar as Volume Control.
| Code: |
<?xml version="1.0" encoding="utf-8"?> |
Modify AndroidVideoPlayer to handle the SeekBar as Volume Control.
| Code: |
package com.exercise.AndroidVideoPlayer; |
The source code for this example ---> HERE
No comments:
Post a Comment