So you want your Android application to be able to change the media volume settings when the user presses the hard key volume buttons on the phone.

The way to do this is to make sure that your Activity class gets a reference of the audio service and override the OnKeyDown() method and catch the keypress event.

Check out the following code:

jPDFNotes’ Sound Annotation object produces raw audio through its getContent() method and an AudioFormat object via its getFormat() method. To convert raw audio to any of its supported audio format, you would have to use Java Sound classes for this to happen.

Below is the method to convert the raw audio to a WAV file.

To use it, do this (assuming “sound” is your Sound Annotation object).

If you want the output returned as an array of bytes (in case you want to convert the WAV to some other format like MP3), you can change the AudioSystem.write() method to use an OutputStream object as the last parameter instead of a File object.

Since my method returns a ByteArrayOutputStream object, you can call the method toByteArray() to have it return in byte[].

Related Posts Plugin for WordPress, Blogger...