Jump to content

Help with sending Custom Intents to Poweramp


andrewilley

Recommended Posts

While I know a fair bit about general use of Poweramp, I've never delved into the black arts of the API and sending Custom Intents. I've just upgraded my Samsung Note phone from KitKat to Marshmallow and so much is no longer the way I want it, or is just plain broken, including using my three-button headset +/- controls for track and album access while the phone is in my pocket.

I've found an Xposed Module (PBMC Key Chains) that with a bit of tweaking gets me 90% of the way there, and I can issue single-click MEDIA_NEXT and MEDIA_PREVIOUS key scancodes, plus use long-press for MEDIA_REWIND and MEDIA_FAST_FORWARD, which only fire while the screen is off. However there does not seem to be a key scancode that causes Poweramp to execute a Next List or Previous List action (for switching albums, folders, etc).

What I can do is issue a "Custom Intent URI" though, which means I need to work out how to format such a command (the editor for such commands is a plain text box). I believe I need to create something along the following lines:

Action: com.maxmpz.audioplayer.API_COMMAND
Extra: cmd:6     ('6' for next item in category, '7' for previous item in category)
Target: Service

Does that seem correct and complete, or have I misunderstood the docs? It doesn't seem to work when I enter that into the Custom Intent URI box anyway.

Andre

Link to comment
Share on other sites

  • 2 weeks later...

Yeah, the Poweramp side of things I'm able to find (it's commands 6 and 7 above that I want), it's how to actually send those intents from PBMC to Poweramp that's not quite so easy.

I created a test shortcut intent in PBMC, which correctly starts a playlist playing in Poweramp, and the created syntax looks like this:

content://com.maxmpz.audioplayer.data/playlists/14/files#Intent;action=com.maxmpz.audioplayer.ACTION_PLAY_IMMEDIATELY;launchFlags=0x20020000;component=com.maxmpz.audioplayer/.PlayListActivity;end

I'm just not sure which bits of the above to replace with the simpler commands that I need...

Andre

Link to comment
Share on other sites

Tried to download xposed but my samsung tab fails to install it. Looking at what you posted and comparing it with the piece of code i posted previously,  you use a slightly different command.

intent.putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.OPEN_TO_PLAY)

the intent looks correct, the uri looks correct too. All i can suggest is that perhaps the intent needs to be launched by "startservice". 

where does the component part come ?

 

Public void playSelectedPlaylist(String playlist_id){

    Intent intent = new Intent(PowerampAPI.ACTION_API_COMMAND);

            intent.putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.OPEN_TO_PLAY)

                    .setData(PowerampAPI.ROOT_URI.buildUpon()

                    .appendEncodedPath("playlists")

                    .appendEncodedPath(playlist_id)

                    .appendEncodedPath("files")

                    .build());

    Intent explicit_intent = new Intent(createExplicitFromImplicitIntent(getActivity(), intent));

    getActivity().startService(explicit_intent);

}

 

 

 

Link to comment
Share on other sites

The sample URI that I posted was only as an example. It was displayed when I chose to create a command to launch a shortcut to a Poweramp playlist, which is another option offered by PBMC. That example works fine, in that when PBMC sends the URI, Poweramp is launched and starts playing the requested playlist. If I change the number '14' to '13' or '12' then I get a different playlist launched.

However I don't want to launch a playlist with the URI, I just want to send a simple 'Next' command (Cmd:6) to move to next Folder, next Album, etc. I can't create any code in this app, merely enter some text into a simple text box which it then interprets and sends. Apparently the general format should be as follows, but I don't know how to slot what Poweramp needs into this layout:

#Intent;action=RUN;component=xeed.app.upnij/.ShortcutActivity;end

Andre

Link to comment
Share on other sites

The options for special actions in PBMC are as per attachment, and clicking on the 'Custom Intent URI' simply opens an empty text box. I got the sample code above by using "Launch Shortcut" and choosing an existing Home Screen Poweramp shortcut (which was already set up to start a playlist) and then viewing the result in the Custom Intent URI editor.

Andre

Screenshot_20170722-163254.png

Link to comment
Share on other sites

Given you only want to go Next, have you tried simply sending a Next command?  i imagine the xposed framework is agnostic whether Poweramp is actually playing a playlist and a next command would fail if no playlist is active but may well work (through the intent) when active.

Link to comment
Share on other sites

The MEDIA_NEXT and MEDIA_PREVIOUS commands work just fine, and I can send those from a long list of scancode/keypress actions that PBMC offers. I can also send MEDIA_REWIND and MEDIA_FAST_FORWARD, which I currently activate using a long-press on the same headset buttons. What I'm trying to generate (which will be the double-click action on the same buttons) is Poweramp's 'Next Album' and 'Previous Album' actions (i.e. Next_in_Cat and Previous_in_Cat in the API list) which as far as I know have no Android keymap equivalents.

 Andre

Link to comment
Share on other sites

Yes, correct. And those are commands #6 (Next_in_Cat) and #7 (Previous_in_Cat) in the list, so all I need to do is work out the right syntax to pass those commands from the button manager's URI sender to Poweramp. 

Andre

Link to comment
Share on other sites

On 6/30/2017 at 6:56 PM, andrewilley said:

Action: com.maxmpz.audioplayer.API_COMMAND Extra: cmd:6 ('6' for next item in category, '7' for previous item in category) Target: Service

Looking at the Pa sample application syntax for the intent  .next or .previous, did you try

Action: com.maxmpz.audioplayer.API.ACTION_API_COMMAND

Extra: com.maxmpz.audioplayer.API_COMMAND:6  (can you replace the semicolon with a comma or does it have to be a :)

Target: Service

Link to comment
Share on other sites

the intent in code looks as follows:

startService(new Intent(PowerampAPI.ACTION_API_COMMAND).putExtra(PowerampAPI.COMMAND,
            PowerampAPI.Commands.NEXT));

or split up:

         Intent  intnt = PowerampAPI.ACTION_API_COMMAND

          intnt.putExtra(PowerampAPI.COMMAND)

         startService(intnt,PowerampAPI.Commands.NEXT)

 

Link to comment
Share on other sites

On 6/30/2017 at 6:56 PM, andrewilley said:

Action: com.maxmpz.audioplayer.API_COMMAND Extra: cmd:6 ('6' for next item in category, '7' for previous item in category) Target: Service

PowerampAPI

* Poweramp Control action.
* Should be sent with sendBroadcast().
* Extras:
*  - cmd - int - command to execute.
*/
ACTION_API_COMMAND = "com.maxmpz.audioplayer.API_COMMAND";
/**
 * NOTE: subject to 200ms throttling.
 */
public static final int NEXT_IN_CAT = 6;
/**
 * NOTE: subject to 200ms throttling.
 */
public static final int PREVIOUS_IN_CAT = 7;

 

You use the correct command but I notice that the number are within an inner class within PowerampAPI. (note the PowerampAPI.Commands.NEXT_IN_CAT below)

Can you replace the 6 or 7 with PowerampAPI.Commands.NEXT_IN_CAT etc and see if that works?

The way I understand this is that by executing these commands, you broadcast to Poweramp which it receives of course. Perhaps you could use Catlog to capture any output in the background and maybe see what is does.

If this does not work then I have run out of ideas. :)

 

Link to comment
Share on other sites

  • 6 months later...

Hello,

After a quick search and skim I think there's no API intent for rating tracks?

I'd just got thumbs up and down from Google Play Music through Tasker with Autonotification following this guide http://forum.joaoapps.com/index.php?resources/press-a-button-on-an-existing-notification-thumbs-up-on-google-play-music.140/I spent some time trying to understand and get GPM's Broadcast Receivers but got to realising this kind of function is hidden closed source and couldn't specifically rate songs without using this notification mod method.

Unfortunately Poweramp doesn't have rating in it's notification so it's not possible this way either. If Poweramp gets next/previous album in notification in future this could be one way for you.

A wildcard idea is if were possible to receive Poweramp's current playing file location via something like intents and then have a helper app to via intents rating tag the file's metadata. Of course this is extra side work for something that would be nice to have in PA's API already. It's just with the state of development and support I figure it's worth considering alternative methods.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...