[App][Alpha] PX5 Media Controller

Search This thread

Bose321

Senior Member
May 21, 2017
463
44
Hi there,

As you might have read on the PX5 board threads, I was struggling with the ease of use of the stock FM Radio app when driving. If you don't have to SWC you first have to press home from navigating, and open the radio app, or use the widgets, to switch channels. I didn't like that like, so I started to inspect the radio and radio widget .apk files. In there I found some pieces of code that remotely allow to control the FM Radio app.

What my app does is 'listen' to the information the stock FM Radio app is outputting. It can get the current frequency and channel. It shows this information on a notification on your HU. This notification also consists of three buttons to go to the previous channel, the next channel, and turn of the radio.

The current frequency and channel are also pushed to the Android Media Session with media button support. This means other apps (like AnyAutoAudio) or widgets can display the currently playing frequency and channel. You can also control the radio with the media buttons Android support. USB keyboards or BT devices that support these buttons should work! I haven't tested it, but this also means the FM Radio can be used in Android Auto. As soon as you open another media app (like Poweramp), that app will take over the media buttons (as expected). If you want to switch back to FM just press the power button on the notification and you're back.

This app is at an early stage right now. I'd like to see it as a proof of concept. It currently only works with FM. It can't show AM information yet. I am not an Android developer, so it might contain a few bugs and glitches. Let me know if you find anything.

I made a little video a few days ago when I had my first proof of concept working. This video does not display the media button support. Watch it here: https://youtu.be/JNUAi0KNGmM

Let me know what you think! Ideas and suggestions are always welcome.

Download: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk
 
Last edited:

Dec64

Senior Member
Jul 20, 2016
111
25
So I gave this ago, it seems like it's nearly there for Android Auto. AnyAndroidAuto does pick it up and displays what station is on but AndroidAutos next/pause/previous buttons do not effect it. Also if I change radio station the widget in AndroidAuto does not update to reflect this. Any idea why this is?
 

Bose321

Senior Member
May 21, 2017
463
44
That's too bad.

Does the info in the notification change when you switch channel? The media session which feeds info widgets etc. seem to be a bit flaky right now.

Do you have any other media widgets that show the current playing media?

edit: @Dec64, gave it a try this morning. My widgets didn't make it control, or had the latest station displayed, but the native Android media buttons worked fine. Very strange... Do you happen to know what commands AnyAndroidAuto send? It should work for the next/previous/pause buttons. I'll see if I can make some changes today.
 
Last edited:

Dec64

Senior Member
Jul 20, 2016
111
25
That's too bad.

Does the info in the notification change when you switch channel? The media session which feeds info widgets etc. seem to be a bit flaky right now.

Do you have any other media widgets that show the current playing media?

edit: @Dec64, gave it a try this morning. My widgets didn't make it control, or had the latest station displayed, but the native Android media buttons worked fine. Very strange... Do you happen to know what commands AnyAndroidAuto send? It should work for the next/previous/pause buttons. I'll see if I can make some changes today.

Yeah the info in the notification changed, and worked perfectly just didn't feed that information down to AA. I had no other media widgets at that time.

No unfortunately I don't know what commands are sent. What is weirder still is this morning on my way to work, after about 20mins the HU turned off the radio and changed menus in AA to the music menu and said nothing is playing...Yet i touched nothing. I put the radio back on and after 5mins it turned back off and I was sent to the phone menu. The only thing new running was your widget, very odd, I dont know how that is even possible.
 

Bose321

Senior Member
May 21, 2017
463
44
Yeah the info in the notification changed, and worked perfectly just didn't feed that information down to AA. I had no other media widgets at that time.

No unfortunately I don't know what commands are sent. What is weirder still is this morning on my way to work, after about 20mins the HU turned off the radio and changed menus in AA to the music menu and said nothing is playing...Yet i touched nothing. I put the radio back on and after 5mins it turned back off and I was sent to the phone menu. The only thing new running was your widget, very odd, I dont know how that is even possible.
Weird! I've rewritten a load of code, and it should be more stable now. I'm testing on an Android Emulator and and simulate some information the FM Radio would send, so I hope it's better now!

You can download the .apk again from the same URL in the first post. Let me know how it works on the HU. I'm gonna test it when I get home tonight.
 

Dec64

Senior Member
Jul 20, 2016
111
25
Weird! I've rewritten a load of code, and it should be more stable now. I'm testing on an Android Emulator and and simulate some information the FM Radio would send, so I hope it's better now!

You can download the .apk again from the same URL in the first post. Let me know how it works on the HU. I'm gonna test it when I get home tonight.

Sweet, ill give it ago in 30mins on the way back from work.
@Bose321 Perfect, works 100% better now, reports, shows station changes when I use SWC to do so, shows a stop button now though instead of pause/next track on the AA widget, and the stop button does nothing, but for AA integration it works
 
Last edited:

Nomader0

Senior Member
Dec 31, 2010
485
62
this is encouraging.
can you help me with something mate:
i need to turn radio on/off via tasker.. do you think there is a way to do that.. i saw you do that via your app
 

Dec64

Senior Member
Jul 20, 2016
111
25
this is encouraging.
can you help me with something mate:
i need to turn radio on/off via tasker.. do you think there is a way to do that.. i saw you do that via your app

You can user tasker or f1x's mtcdtools to do that, there's an intent to close the radio app.

intent action: com.microntek.finish
intent parameters: {"class":"com.microntek.radio"}
 

Bose321

Senior Member
May 21, 2017
463
44
Sweet, ill give it ago in 30mins on the way back from work.
@Bose321 Perfect, works 100% better now, reports, shows station changes when I use SWC to do so, shows a stop button now though instead of pause/next track on the AA widget, and the stop button does nothing, but for AA integration it works
Can you show the AA interface? Not sure why there only is a stop button now, and why it doesn't work. I'll have to dig around in the code to see what causes that.

edit: I think I already know why there only is a stop button right now! Gonna push out a fix tomorrow! I also think why the stop button doesn't work. I only listen to the pause/play button, not the stop button. Thanks for testing, this is useful!

this is encouraging.
can you help me with something mate:
i need to turn radio on/off via tasker.. do you think there is a way to do that.. i saw you do that via your app
I use the intent "hct.radio.power.switch" to turn the radio on or off. This is different from the intent Dec64 posted. Mine only turns off the radio, it doesn't shut down the radio app. So use what fits the most.
 
Last edited:

Nomader0

Senior Member
Dec 31, 2010
485
62
Can you show the AA interface? Not sure why there only is a stop button now, and why it doesn't work. I'll have to dig around in the code to see what causes that.

edit: I think I already know why there only is a stop button right now! Gonna push out a fix tomorrow! I also think why the stop button doesn't work. I only listen to the pause/play button, not the stop button. Thanks for testing, this is useful!


I use the intent "hct.radio.power.switch" to turn the radio on or off. This is different from the intent Dec64 posted. Mine only turns off the radio, it doesn't shut down the radio app. So use what fits the most.

Thanks for your answers..
Which intent turns on the radio?

Maybe Com.microntek.radio.power?
 
Last edited:

Bose321

Senior Member
May 21, 2017
463
44
Sweet, ill give it ago in 30mins on the way back from work.
@Bose321 Perfect, works 100% better now, reports, shows station changes when I use SWC to do so, shows a stop button now though instead of pause/next track on the AA widget, and the stop button does nothing, but for AA integration it works
Can you give it another try? I've updated the link in the first post again. Should now show next/previous/play-pause buttons if I'm right!

Tried the version of yesterday in my car, and it works a lot better for sure!

Are you liking Android Auto on the HU? Is it fast? I'm hoping Sygic is able to build the navigation for AA soon, I don't like Google Maps for offline navigation. Are you always connected via your phone or something, or have you downloaded parts of maps?
 

Dec64

Senior Member
Jul 20, 2016
111
25
Can you give it another try? I've updated the link in the first post again. Should now show next/previous/play-pause buttons if I'm right!

Tried the version of yesterday in my car, and it works a lot better for sure!

Are you liking Android Auto on the HU? Is it fast? I'm hoping Sygic is able to build the navigation for AA soon, I don't like Google Maps for offline navigation. Are you always connected via your phone or something, or have you downloaded parts of maps?

I will try it on the way home from work again.

I like AA on my HU because it displays the info i need quickly and at all times, but the major draw backs where the radio not showing, and the phone menu not working properly.

I dislike google maps and prefer waze for the police/speed camera warnings as i drive a bit...spirited...but waze integration isn't working yet unless you have an AA specific HU. It also doesnt display speed limits/cameras.

Yeah I have 30gb of tethering on my phone so always connected using tasker to start tethering when BT is connected
 

Dec64

Senior Member
Jul 20, 2016
111
25
tried updated app. Next/previous/stop now show on widget but do not work in AA, everything else works perfectly
 

Bose321

Senior Member
May 21, 2017
463
44
tried updated app. Next/previous/stop now show on widget but do not work in AA, everything else works perfectly

Weird! I'll see if I can get AA on a device to test this. At least the right buttons are now showing. It's a start... :laugh:

Seems to be different from other widgets, because the ones I use seem to work fine (Ubiquity Music Widget).
 

Dec64

Senior Member
Jul 20, 2016
111
25
Just turned rds on my radio and noticed the widget doesn't pick station name or rds info. It would be amazing if it could and report that info?
 

Bose321

Senior Member
May 21, 2017
463
44
Just turned rds on my radio and noticed the widget doesn't pick station name or rds info. It would be amazing if it could and report that info?
I've been looking into that, but I believe the radio app doesn't 'share' that information. But I'll have another look.

But first gotta look into the AA issue.

What I did notice on my own HU, as soon as the Radio app starts, the sound goes on, and directly off again at boot. Did any of you notice that?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    Hi there,

    As you might have read on the PX5 board threads, I was struggling with the ease of use of the stock FM Radio app when driving. If you don't have to SWC you first have to press home from navigating, and open the radio app, or use the widgets, to switch channels. I didn't like that like, so I started to inspect the radio and radio widget .apk files. In there I found some pieces of code that remotely allow to control the FM Radio app.

    What my app does is 'listen' to the information the stock FM Radio app is outputting. It can get the current frequency and channel. It shows this information on a notification on your HU. This notification also consists of three buttons to go to the previous channel, the next channel, and turn of the radio.

    The current frequency and channel are also pushed to the Android Media Session with media button support. This means other apps (like AnyAutoAudio) or widgets can display the currently playing frequency and channel. You can also control the radio with the media buttons Android support. USB keyboards or BT devices that support these buttons should work! I haven't tested it, but this also means the FM Radio can be used in Android Auto. As soon as you open another media app (like Poweramp), that app will take over the media buttons (as expected). If you want to switch back to FM just press the power button on the notification and you're back.

    This app is at an early stage right now. I'd like to see it as a proof of concept. It currently only works with FM. It can't show AM information yet. I am not an Android developer, so it might contain a few bugs and glitches. Let me know if you find anything.

    I made a little video a few days ago when I had my first proof of concept working. This video does not display the media button support. Watch it here: https://youtu.be/JNUAi0KNGmM

    Let me know what you think! Ideas and suggestions are always welcome.

    Download: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk
    2
    Worked a bit on the default music integration. It's still not done yet obviously, but I've got a proof of concept running on my HU right now. Switching between radio and music is a little tricky, but it's a good start. I hope to fix some bugs tomorrow and push out a version to test.

    It seems that only the song name (filename.mp3) is only available, so that's a little crappy, but I'll see if I can get some more info somewhere... :good:
    2
    Hey,
    I tested and its working good so far :) nice update, thank you.
    Great to hear. I haven't found time yet to improve the music part yet, but I have a nice update for the radio part!

    Thanks to the help of @AndHead I have now found out how to retrieve the radio station name and RDS information from the current station. I've also worked on a little extra way of controlling the media in the form of a floating widget that overlaps the screen so you can use it in all screens. If you're familiar with the 'chat heads' from Facebook you might know what it can do. Because it's still experimental and looks ugly I've made a setting for it for people to try. I would like to hear what colors and layout you people would like to see for this for optimal usage!

    I've updated the link in the first post: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk

    Let me know how it works!
    1
    Do you plan to build a solution for the stock media player as well? or maybe integrate that into your app? That would be gorgeus!
    Btw, this also works for Intel Sofia, not onlx PX3 and 5
    Actually I was thinking about that! Maybe I should have a look at this this week.

    That's cool! Does that HU use the same radio and music player?
    1
    I managed to get it working. Seems that it only works with Android 6 and above. Anyways this is a great program, at the moment the stock radio doesn't notify when I change preset radio channel. So when I combine this program with 'Heads Up! Notifications', it will popup notifications when I change the channel.

    I only have one request, if you are able to add the option to disable the RDS. Reason being when ever the RDS info changes, it will appear the notifications, so it's best to make it a static info i.e. Radio Frequency. If you are able to add this, it would be a perfect program for me.

    Thanks
    Sounds possible. I think I could just add a checkbox (like for the experimental floating window) to enable/disable RDS. When I find some free time I'll work on that.