• Announcements

    • andrewilley

      Poweramp v3 Project Update   04/24/2017

      As you may be aware, the Poweramp developer has been working hard on an updated material design user interface for Poweramp v3 which required a full ground-up rebuild of the code and is taking some time to get to a beta-test stage. See the forum thread for more details and to discuss.    
Sign in to follow this  
Followers 0
andrewilley

Help with sending Custom Intents to Poweramp

17 posts in this topic

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

Share this post


Link to post
Share on other sites

Perhaps you are already familiar with this but I had a look in the api code and found the commands as shown in the attached screenshot:

Other commands do not appear to have been implemented

 

commands.PNG

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

So no one has any idea how to format a Custom Intent URI for sending to Poweramp?

Andre

Share this post


Link to post
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);

}

 

 

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

It is my understanding that only the commands shown in my earlier screenshot have been implemented in the api

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I think it seems to use semicolons as separators, looks like it just accepts one line of code. I tried pretty much what you've posted, but I'll give it a go again. "#Intent" seems to be a required component too.

Andre

Share this post


Link to post
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)

 

Share this post


Link to post
Share on other sites

Where does the actual command number ('6', '7', etc) go in that command syntax?

Andre

Share this post


Link to post
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. :)

 

Share this post


Link to post
Share on other sites

I'm waiting for some help from the PBMC app developer too, will let you know what he suggests.

Andre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0