Get currently playing music app - android

I am using this tutorial and the RemoteController to control the currently playing music player:
http://forum.xda-developers.com/showthread.php?t=2579415
Is there a way to get the application/package of the currently playing music application? I want to be able to open it.
I'm sure it is possible somehow as Aviate manages to do it, but afaict this class does not provide that information:
https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener.html
Maybe there is some unrelated way of getting the currently playing music player...
Thanks :)

I worked it out... had to use reflection on the RemoteController though.
Method method = mRemoteController.getClass().getDeclaredMethod("getRemoteControlClientPackageName");
if (method != null) {
return (String) method.invoke(mRemoteController);
}

Related

How to get active music player -- android

thanks for previous replies,
Is it possible to get package name of active and runningin service(background) music player. I can able to get the music actions(metachage or playstateChange) but when i use intent.getPackagename, im getting null. can anyone guide me on how to get the package name of music player.
Thanks!
Supplying the file URL and open it in browser does not make sense, because this URLs expire after a wile.
No, insofar as there is nothing magic in Android that denotes a "music player" from anything else.

Detect Microphone State Change on Android to detect audio recording

I was trying to make an Android APP whose main function is to detect
if other android APPs are recording voice using Microphone. So far, I learned
that getRecordingState() from AudioRecord class can be used to get the state
of whether microphone is recording or not... but I need something like a broadcast
so I can catch the intent while the state of microphone starts to record voice...
any idea ? Thanks in advance!!
getRecordingState() returns the state for the particular AudioRecord instance that you call the method on. It doesn't give you some global state for all recorders.
There's currently no API available for applications to check globally whether there's ongoing recording from the microphone. The AudioFlinger has that information (though not about which specific application that is doing the recording), but the only way for you to get hold of it would be to modify Android itself and run your own custom Android version.
Try AudioManager.isMicrophoneMute()
http://developer.android.com/reference/android/media/AudioManager.html#isMicrophoneMute()

Playing Audio During call so that other person on call can hear it

i am developing one application which
needs to play an audio song to callee when call is lifted by callee,
and automatically call has to be disconnected automatically when audio
song playing completed . i tried to find in android API for any
classes or methods to do this, but failed to find... please help me
how to do this..
your answer could be helpful to me...please do reply
Thank you in advance..
AFAIK, it is not possible to play a sound in the ongoing call and also to automatically dosconnect a call. Telephont API doesnt provide any methods to do any od these. So both od these requirement can't be fullfilled in ANdroid.

Send music control keys from my app in android

Is there a simple way to tell the default media player to change track back or forward?
I want the ability to send commands to the system media player (Music) to change track back and forward from within my app.
Is there a simple way? Code examples or descriptive explanation please, I have not developed for Android before.
Update: Is it just the HTC Music that isn't part of the SDK or even the stock one? Either player would be fine if I could manage way to change tracks.
The HTC Lock screen has some method of changing tracks in the music player. Is it possible I could get hold of this and use it?
Baksmali?
I want the ability to send commands to
the system media player (Music) to
change track back and forward from
within my app.
The Music application is not part of the Android SDK, so there are no documented and supported Intents for moving from track to track.
Sorry!
by ACTION_MEDIA_BUTTON using intent ??
http://developer.android.com/reference/android/content/Intent.html#ACTION_MEDIA_BUTTON
Intent media_intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
media_intent.setPackage(DEFAULTPLAYER);
synchronized (this) {
media_intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keycode));
mContext.sendOrderedBroadcast(media_intent, null);
media_intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, keycode));
mContext.sendOrderedBroadcast(media_intent, null);
}
however DEFAULTPLAYER needs to be assigned...
:S :S :S

Receiving MP3 play actions in a BroadcastReceiver in Android

I am trying to build an Android Service that should get notified when the user starts playing an MP3. I checked LogCat when I start playing a song and saw that the following Intent is logged:
Intent { act=com.android.music.PLAYBACK_VIEWER flg=0x4000000 cmp=com.android.music/.MediaPlaybackActivity }
I couldn't figure out how to write an IntentFilter to let my Service know that this event has occurred and let me know the name of the song that will be played. I searched Android reference but could not find anything on PLAYBACK_VIEWER.
Thanks,
C
I would do neither. First, none of this is part of the SDK and so may change at any point. Second, this will only work for the built-in media player application, not any third-party or OEM-supplied media players, and I expect more people to gravitate to those.

Categories

Resources