Hi guys,
I've added a new feature especially useful for advanced users.There's a new available Intent action.
"com.cav.foobar2000controller.GET_PLAYING_SONG"
It will allow you to get the current song info via Intent without havng to care about http requests or foobar2000 HTTP Control API.
Unlike previous Intent actions, this one is a bit more complicated to work with, but it's actually fairly easy.
You'll need to send a broadcast specifying a callback Intent action string for me to send you back the information in form of JSON-like string.
Here's an example:
Sending the Broadcast
// Create a Bundle with the action you want to be called from foobar2000 controller
Bundle extras = new Bundle();
// This is mandatory! The key MUST BE "callbackAction". The action "com.mybroadcast.song_info" can be any of your choice
extras.putString("callbackAction", "com.mybroadcast.song_info");
// Create a new Intent. Set the new action and add the extras.
Intent intent = new Intent();
intent.setAction("com.cav.foobar2000controller.GET_PLAYING_SONG");
intent.putExtras(extras);
// Send the Broadcast. foobar2000 controller will receive it and send you back a Broadcast with the song informationReceiving the information
sendBroadcast(intent);
// You need to have a BroadcastReceiver. It can be a custom class of yours.
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
// This is where the song info is stored.
// It will be like: {"title":"Song title", "artist":"Song artist", "album":"Song album", "length": 123, "rating":5}
// You can convert it to JSONObject (or any other implementation)
String song = extras.getString("song");
// Do whatever you want with the retrieved song.
Toast.makeText(MainActivity.this, song, Toast.LENGTH_LONG).show();
}
}
};
// Register the receiver with the action you've provided before
registerReceiver(broadcastReceiver, new IntentFilter("com.mybroadcast.song_info"));
Here's a full Android studio project example using this new Intent action;
https://www.dropbox.com/s/vyuuiyjlgwkavcs/SendBroadcastTest.zip?dl=1
Enjoy!
https://www.dropbox.com/s/vyuuiyjlgwkavcs/SendBroadcastTest.zip?dl=1
Enjoy!
In the new version of the controller does not connect to the server.
ReplyDeleteHi
ReplyDeleteThe app is very good but I have an issue with it on my Nexus 5 and 7. When I select an album from the library to play, if I navigate away from the app and then BACK to it, the folder view shifts up from the album to its artist, thus adding all of the artist's albums to the playlist. Consequently, at the end of an album, rather than foobar stop playing, it goes on to the next album in line. How do I stop this from happening?
In addition, the app needs to have a Sort By disc number function. At present it messes up the track order with multi disc albums.
Many thanks, Robert.
Did you realize there is a 12 word phrase you can tell your partner... that will trigger intense feelings of love and instinctual attractiveness for you buried inside his heart?
ReplyDeleteBecause deep inside these 12 words is a "secret signal" that triggers a man's impulse to love, adore and protect you with all his heart...
12 Words That Trigger A Man's Love Impulse
This impulse is so built-in to a man's brain that it will make him work better than before to to be the best lover he can be.
In fact, triggering this all-powerful impulse is so important to achieving the best possible relationship with your man that the moment you send your man a "Secret Signal"...
...You'll immediately find him expose his soul and heart to you in a way he's never experienced before and he will identify you as the only woman in the universe who has ever truly understood him.