What is RemoteControlClient in Android 4.0? - android

I know the rules of StackOverflow and hence apologize beforehand for asking such a subjective question.
I tried the documentation but all it says is this :
RemoteControlClient enables exposing information meant to be consumed
by remote controls capable of displaying metadata, artwork and media
transport control buttons.
A remote control client object is associated with a media button event
receiver. This event receiver must have been previously registered
with registerMediaButtonEventReceiver(ComponentName) before the
RemoteControlClient can be registered through
registerRemoteControlClient(RemoteControlClient).
I don't know about others but for me, this much of documentation was not enough for something which has such a cool name as "RemoteControlClient".
I searched a lot of forums for this but unfortunately, the concept is still not clear to me.
Would indeed be grateful if someone helped me understand it, how it works and most importantly, what all it is capable of.
Thanks in advance and apologies for asking a subjective question.

http://developer.android.com/about/versions/android-4.0.html
The new RemoteControlClient allows media players to enable playback controls from remote control clients such as the device lock screen. Media players can also expose information about the media currently playing for display on the remote control, such as track information and album art.
and a few more paragraphs on the subject.
It also points out:
For a sample implementation, see the Random Music Player, which provides compatibility logic such that it enables the remote control client on Android 4.0 devices while continuing to support devices back to Android 2.1.

Related

Android WebRtc play dialing sound for outgoing calls

I'm working on a project that involves WebRtc for Android and everything is working fine accept for the fact that I don't know how I can play the standard repeating beep sound when you are waiting for that the person you are calling accepts your call.
I have searched a lot for this but accept for a link that was related to IOS which wasn't very helpful, there was nothing useful.
Does anybody know how I can accomplish this?
AFAIK there's is no special "API to play this kind of sound". It's just like playing any other sound. Asking how to find an "outgoing" rings.wav on the internet, is out of scope for stackoverflow.
If you're looking to generate it, you'd need to specify which sound you want, since there is no "standard" one. The sound varies from market to market. Traditionally even, on old POTS networks, the sound was literally sent from the other side, producing different sounds when calling people in other countries.
Also, "ringing" is an app choice, and out of scope for WebRTC. Most WebRTC apps these days tend to pair people up using "rooms" or similar abstractions, rather than the traditional "pick up!" model.

How does the bluetooth a2dp profile work?

I want to create a bluetooth music player application which streams audio from one device to another. I have read everything on the android developers page about bluetooth and I found that a profile called a2dp has been specifically created for audio streaming. However not much has been provided on how to use it. I have also gone through the bluetooth chat example but i have been unable to figure out how to actually send audio and how to receive it. I have also read that a2dp sink functionality has been added as of android 5.0.
After spending hours on stackoverflow I see numerous questions asking the same thing but without any satisfactory answer.
My main questions are-
How does the bluetooth a2dp profile work?
Are there better methods to implement audio streaming between
android devices apart from a2dp?
Any help would be greatly appreciated.
You can read the AVDTP core specification to know what happens during an a2dp connection.
But if you want to know about the working of it in terms of coding, I suggest you go through this blog which I found useful.

Live Streaming and conversation in the stream

I intend to realise an app and my first trouble is : is it even possible ? Let me explain to you.
The app must allow people to stream live channel that are broadcasting audios. Nothing hard here. The channel's owner can choose which specific people are allowed to listen to his channel (still nothing hard) but also which people can react among them. Yes it must allow people to talk in the audio stream too. In this part it will be like a hangout or skype-like. The stream also has a limited time (1-hour maybe).
So basically the app allow to make live audio stream and people can react in that stream.
Do you guys have any direction or even intuition in the feasibility of such a thing ? Thanks you.

Why it is not possible to play an audio file on a voice call in android

This question might seem to be a repetition of the questions such as following:
How to play an audio file on a voice call in android
Background Audio for a Call in Progress - Possible?
The answers of these questions suggests that it is not possible to play a pre-recorded audio on a voice call in android. I want to know why it is not possible? What is the limitation (hardware/software)? Is it really a limitation or done purposely? Can we alter the source code of android to make it possible?
I think this is a limitation, imposed for security reasons and restricted at the OS level.
Let's analyze the security threat, first of all. If you were able to play custom audio files to the callee, a whole world of cons opens up: you could trick customer supports, you could pretend to be someone else, you could give unauthorized purchase confirmations, and so on. For this reason, neither Android nor iOS allows this functionality.
On Android, you won't be able to do so in a programmatic way, simply because the current APIs won't allow you to do so. It is stated in the official documentation as well, as pointed out here. If you dig into the source code, you can probably enable this feature by accessing the microphone output during a phone call, but that would require running your custom version of Android. A good starting point would be the AudioTrack source, available here.
EDIT: a good example of an audio mod involves enabling the Nexus 5 earpiece as a second loudspeaker (requires root). Can be found here.
After a thorough research, what I have come to know is that there are more than one limitations/hurdles to make it possible. These limitations/hurdles are at three different levels.
First limitation is at API level, because there is no high-level API to play sound files in the conversation audio during a call as mentioned in Android official documentation.
Second limitation is at Radio Interface Layer (RIL). RIL passes on complete control of the call to Radio Daemon (rild) of the Linux library which then further passes the control to the vendor RIL. That means we cannot manipulate voice call in android source code.
Even if we are able to remove these two limitations, we may still not be able to play audio file to an ongoing voice call. Because there is a third limitation. Every vendor has their own library of RIL that communicates with Radio Daemon (rild). This requires that vendor RIL to be open source which is not actually. Hardware vendors do not usually make their device drivers code available.
Detail discussion on this topic is present at this link.
This is software related due to the prioritization of audio routing in Android.
Take a look into the CallManager where you can dig into the method setAudioMode(). After the audio mode was set to MODE_IN_COMMUNICATION the following code is called
audioManager.requestAudioFocusForCall(AudioManager.STREAM_VOICE_CALL,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
From this point on the telephony service has the highest priority and won't let any other audio play in parallel.
Note: You can play back the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call.
See official link
http://developer.android.com/guide/topics/media/mediaplayer.html
By implementing the AudioManager.OnAudioFocusChangeListener you can get the state of the audiomanager. so by this if any music is playing in the background you can get the AudioManager states(playing and pausing is completely in developer hands) similarly......
Some of the native music players in android device where handling this, they restrict the music when call is in TelephonyManager.EXTRA_STATE_OFFHOOK.so this scenario is also completely in developer hand (whether to handle or not) if he is not handling both will play parallel y

Audio Framework: stream, strategies, devices

I am trying to get a better understanding of android audio framework (froyo onwards in particular).
I've almost got the distinction into streams. The AudioFlinger maps each stream into a "strategy" and then routes a strategy to the proper "device" (BT, Headset, Speaker..)
However I still struggle to understand:
1) How multiple apps play onto the same stream? can they just 'play' or do they have to handle the focus (request, abandon and listen for changes)?
2) When multiple streams are playing...what is the priority of one stream respect to another? surely the in-call stream has top priority but are there any "rules" to understand how things really work.
If anyone with more confidence on this matter has got any doc/resource to study.. it would be great.
Thanks!
Marco
The answer to this question
Concurrent Sound on Android Device
may help you.
Also, here
http://www.droidnova.com/creating-sound-effects-in-android-part-1,570.html
is written how to initialize the SoundManager with the number of concurrent streams you want to play.
If you need to understand the default behavoiur you can see the Cplusplus code at
/hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp
However each vendor can make changes and ship a different flavour

Categories

Resources