MKK
MKK

Reputation: 2753

How can I enable volume control in my App?

My app is simply built as a simple web browser. So main part is completely just webview.

When it plays youtube on the page, it won't allow me to turn the volume up even if i hit hard key.
It obviously doesn't show the volume slider, either.

How can I enable that? I tried to add this below

To Manifest

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

To MainActivity

    protected void onCreate(Bundle savedInstanceState) {
        setVolumeControlStream(AudioManager.STREAM_MUSIC);

Upvotes: 0

Views: 138

Answers (1)

Kestrel12
Kestrel12

Reputation: 124

I'm not sure on this, but you might need to set the VolumeControlStream in the activity that's actually playing the audio, which might not be your MainActivity

Upvotes: 1

Related Questions