Thanks for the reply Sachin, but I'm not sure how to check for user
permission for changing audio manager.

Anyways I found the mistake that I was doing. First we need to
instantiate the AudioManager object as:
MyAudio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

now getStreamVolume(streamType) and setStreamVolume(streamType, index,
flag) will do the trick.

But now I'm stuck at another problem. This method increases/decreases
the volume of the system (in my case the emulator). I want to keep the
volume of the system as it is and increase/decrease the volume of just
the application. Such that the application volume level will vary
between 0 and current system volume level.

Any help will be appreciated. Thanks in advance.

On Jun 9, 10:55 pm, sachin ravi <[email protected]> wrote:
> Just check for user permission for changing audio manager and add in the
> AndroidManifest file.
>
> On Tue, Jun 8, 2010 at 11:15 AM, Alok <[email protected]> wrote:
> > Hello,
>
> > I have some years of experience in C/C++ and bit of Java programming
> > in Linux, but I'm new to Android.
>
> > For start I'm trying to develop a video player on android. I'm able to
> > play the video using the VideoView widget. But when I'm trying to
> > control the volume using AudioManager, the application crashes saying:
> > "The application Video (process com.android.video) has stopped
> > unexpectedly. Please try again."
>
> > If it helps : I've downloaded the Android source (ECLAIR) and using
> > the sdk directly from the source and I'm using Eclipse 3.1.1. I've
> > successfully run the sample apps from the source code.
>
> > The following is a snapshot of what I'm trying to do in my code:
>
> > [code]
> > package com.android.video;
> > ....
> > import android.media.AudioManager;
> > ....
> > public class Video extends Activity {
> >   .
> >   .
> >   private AudioManager MyAudio;
> >   .
> >   .
> >   .
> >   MyVolUp.setOnClickListener(new OnClickListener(){
> >      public void onClick(View view) {
> >            MyAudio.adjustStreamVolume(MyAudio.STREAM_MUSIC,
> > MyAudio.ADJUST_RAISE, MyAudio.FLAG_PLAY_SOUND);
> >            }
> >      });
> >   .
> >   .
>
> > [/code]
>
> > 1. What am I doing wrong here?
> > 2. I was going through the Android source and saw that AudioManager
> > (even MediaPlayer) are using the native functions for handling audio.
> > How can I use those native function (just for experimenting, not
> > related to my project) in my application? We can do it using JNI but
> > I'm not sure how to use the native functions already there in android.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to