android-audiomanager

How to expose variable from HAL to shared libraries present in system/lib/hw (android)?

家住魔仙堡 提交于 2019-12-13 19:12:22
问题 I made some changes in the platform specific existing HAL, and I want this changes to be get selected when I start my audio stream. For this I need to differentiate it from other streams, so I added a variable in HAL and I wanted it to be exposed to my shared library that I will be pushing to system/lib/hw directory, so that when I start my stream I set this variable in my .so So that in HAL I can differentiate it from other streams. Any ideas to expose the variable in HAL to shared library

Play sound either from external or internal speaker programmatically

可紊 提交于 2019-12-13 06:59:57
问题 Suppose I have a MediaPlayer class object which is playing some music. Now I want to change the music to play either from device's internal speaker or already plugged in earphone. Let's say just by tapping a button. Is that possible? 回答1: I can't comment becuase I don't have enough reputation, so I'll post it. Just do a small quick search: Switching between earpiece and speaker import android.media.MediaPlayer; import android.media.AudioManager; public class MediaPlayer { private MediaPlayer

How to use MediaSession.setMediaButtonReceiver(PendingIntent) to resume playback

て烟熏妆下的殇ゞ 提交于 2019-12-12 18:15:12
问题 I'm trying to be able to start music playback from my app when the headset buttons are clicked while my app is stopped. I can use MediaSession.Callback onMediaButtonEvent() or the now deprecated registerMediaButtonEventReceiver() to listen for media button click WHILE my app is playing music, but if I pause the music for a minute, with my Activity and playback Service still running, and then I press the headset button, I see that I have lost the ability to receive the media button broadcast.

Play / Record .DSS or .DS2 files

给你一囗甜甜゛ 提交于 2019-12-12 10:48:57
问题 I have a project running which should allow to play and eventually also record .DSS ("Digital Speech Standard") and .DS2 ("Digital Speech Standard Pro") audio files. However, I can't seem to find anything about it. Is there any way possible to achieve this or any library possibly there to get it up and running? I am atm using the android built-in android.media.MediaPlayer, if this is useful anyhow. Thanks in advance. 回答1: I have checked this out too. DS2 and DSS is proprietarily owned by

What is the default audio stream of TTS?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 08:27:08
问题 As far as I can tell, there are currently are 7 audio streams in Android: STREAM_ALARM (for alarms) STREAM_DTMF (for DTMF Tones) STREAM_MUSIC (for music playback) STREAM_NOTIFICATION (for notifications) STREAM_RING (for the phone ring) STREAM_SYSTEM (for system sounds) STREAM_VOICE_CALL (for phone calls) I also know that it is possible to explicitly tell the TTS engine which stream to use: params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM)); mTts.speak

KeyEvent.ACTION_UP fired TWICE for ACTION_MEDIA_BUTTON

旧街凉风 提交于 2019-12-12 07:44:57
问题 I have this broadcast receiver for ACTION_MEDIA_BUTTON which actually works for both Android 2.x and Android 4.1, but for some strange reason, on Android 2.x (only) , I get each even twice (for a single click on the pause button, of course): public class RemoteControlReceiver extends BroadcastReceiver { private static long prevEventTime = 0; @Override public void onReceive(Context ctx, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent

Play sound through earpiece when using MediaPlayer

对着背影说爱祢 提交于 2019-12-12 06:20:06
问题 I am playing voicemail recordings in my app. The way I currently have it set up, it plays the voicemail through the speakerphone. What is the best way to be able to toggle between speakerphone and earpiece. Here is how I set up my MediaPlayer: mediaPlayer = new MediaPlayer(); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); }

Android, how to route the audio to speakers when headphones inserted?

筅森魡賤 提交于 2019-12-11 20:09:55
问题 I am looking for a way to play audio from an Android device's speaker, even when headphones are inserted. In fact, the typical behavior is that, when headphones are inserted, no audio is outputted form the speakers. However some apps, such the default Clock app (com.google.android.deskclock), are able to route the audio to the speaker even when the headphones are inserted. How can I programmatically get this behavior? I am looking for a solution that works (at least) on Nexus 5 devices,

Need a simple demo for only check whether background Music running or not? [duplicate]

人走茶凉 提交于 2019-12-11 19:40:09
问题 This question already has an answer here : How to detect that music play in background (1 answer) Closed 11 months ago . I need a simple demo, In which I want to check whether the music is running in the background or not? And also does not effected on the music which is running in Background I read from here study Link and made a demo code Demo code is here but this is not giving me the O/P: AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); AudioManager.STREAM_MUSIC

audioManager.getstreamVolume(AudioManager.STREAM_RING) always returning 0

三世轮回 提交于 2019-12-11 12:35:42
问题 I am trying to get the ring volume, but it always gives 0, regardless of what volume I have set it to (I do this by accessing it via Settings on the phone). audioManager.getstreamVolume(AudioManager.STREAM_RING) The same API works properly with the other audio streams AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_MUSIC, etc. Could anyone let me know why this is happening and how I can correct it? 回答1: Your code is correct. The call returns 0 when your phone is in mute or vibration