How do you get/set media volume (not ringtone volume) in Android?

private AudioManager audio; Inside onCreate: audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); Override onKeyDown: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; default: return false; } }

Can Java Sound be used to control the system volume?

No, it cannot. Here is source adapted from an answer to Adjusting master volume on coderanch. The source iterates the available lines, checks if they have a control of the right type, and if so, puts them in a GUI attached to a JSlider import java.awt.*; import javax.swing.*; import javax.sound.sampled.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public … Read more

Mute Windows Volume using C#

Declare this for P/Invoke: private const int APPCOMMAND_VOLUME_MUTE = 0x80000; private const int WM_APPCOMMAND = 0x319; [DllImport(“user32.dll”)] public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); And then use this line to mute/unmute the sound. SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr) APPCOMMAND_VOLUME_MUTE);

iOS: Change Device Volume

Using iPodMusicPlayer would affect the actual iPod volume setting as well. If you want to avoid that, use this: #import <MediaPlayer/MediaPlayer.h> // … MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer]; musicPlayer.volume = 1.0f; As the user holex correctly mentioned the property volume in MPMusicPlayerController is deprecated in iOS 7.

How to change device Volume on iOS – not music volume

To answer brush51’s question: How can i do that? just change the DEVICE volume? As 0x7fffffff suggested: You cannot change device volume programatically, however MPVolumeView (volume slider) is there to change device volume but only through user interaction. So, Apple recommends using MPVolumeView, so I came up with this: Add volumeSlider property: @property (nonatomic, strong) … Read more