Jump to content

send intent to play specified folder using tasker


Arielcity

Recommended Posts

hello,

i want to play specified folder in Poweramp with send intent using tasker

hear is the code in tasker:

A1: Send Intent [ 
    Action:com.maxmpz.audioplayer.API_COMMAND 
    Cat:None 
    Mime Type: 
    Data:content://com.maxmpz.audioplayer.data/folders="Bla Bla" 
    Extra: cmd: 20 
    Extra: shuffle: 2 
    Extra: 
    Package: 
    Class: 
    Target:Service ] 

But this doesn't work.

What is wrong with this code?

Hear are some stuff from  PowerampAPI.java

/**
* Data:<br>
* - uri, following URIs are recognized:<br>
* - file://path<br>
* - content://com.maxmpz.audioplayer.data/... (see below)<br><br>
*
* # means some numeric id (track id for queries ending with /files, otherwise - appropriate category id).<br>
* If track id (in place of #) is not specified, Poweramp plays whole list starting from the specified track,<br>
* or from first one, or from random one in shuffle mode.<br><br>
*
* All queries support following params (added as URL encoded params, e.g. content://com.maxmpz.audioplayer.data/files?lim=10&flt=foo):<br>
* {@code int lim} - SQL LIMIT, which limits number of rows returned<br>
* {@code String flt} - filter substring. Poweramp will return only matching rows (the same way as returned in Poweramp lists UI when filter is used).<br>
* {@code int shf} - shuffle mode (see ShuffleMode class)<br>
* {@code int shs} - 1 if this is shuffle session (for internal use)<br><br>
<pre>
 
- Plain folders view (just files in plain folders list)
content://com.maxmpz.audioplayer.data/folders
content://com.maxmpz.audioplayer.data/folders/#
content://com.maxmpz.audioplayer.data/folders/#/files
content://com.maxmpz.audioplayer.data/folders/#/files/#
 
- Hierarchy folders view (files and folders intermixed in one cursor)
content://com.maxmpz.audioplayer.data/folders/#/folders_and_files
content://com.maxmpz.audioplayer.data/folders/#/folders_and_files/#
content://com.maxmpz.audioplayer.data/folders/files // All folder files, sorted as folders_files sort (for mass ops).

**/

 

Link to comment
Share on other sites

The uri would be  Data:content://com.maxmpz.audioplayer.data/folders/1

That means id is required (# == id). To know id you should query Poweramp database, etc. so it won't be easy if you want just to play something with a simple intent.

Instead I suggest using android.media.action.MEDIA_PLAY_FROM_SEARCH with free-form search text:

 Send Intent [ 
    Action:android.media.action.MEDIA_PLAY_FROM_SEARCH 
    Cat:None 
    Mime Type: 
    Data:
    Extra: query: YOUR SEARCH STRING HERE
    Extra: android.intent.extra.user_query: shuffle
    Package: com.maxmpz.audioplayer
    Class: com.maxmpz.audioplayer.ListActivity
    Target:Activity ] 

But this is API is for free format/voice search, so it can't "focus" on folders, it supports targeting on genres/artists/albums or just songs. Also, for specific shuffle mode you need to send additional command, as search query supports just shuffle (and that android.intent.extra.user_query:  depends on device system language).

 

Link to comment
Share on other sites

Hi,

I'm also looking for a way to play music from specified folders (with MIT App Inventor)!  Too bad it's not possible, I'll try your workaround maxmp but it looks tricky, if anyone has another solution I'm interested ;)

 

Link to comment
Share on other sites

@BMO it’s possible, but again you should know/get id of the folder first (it can be done via Poweramp API). Or alternatively, search can be used (provided that on android, esp. for latest versions you can’t use path to identify folder anyway).

I’m open for suggestions to improve this, for example, I think it’s possible to add some 1-liner intent to search/play given folder by name (as it’s available now for albums/artists/genres/playlists, that will fail/play invalid folder if there are multiple of them with similar subpath, though).

Link to comment
Share on other sites

I made some tests to get familiar with Poweramp intents but it's not working really well ?! I can create another topic if you prefer but I feel I'm close. 

- MEDIA_PLAY_FROM_SEARCH didn't work with android.media.action.MEDIA_PLAY_FROM_SEARCH as you mentioned but with the path specified in the doc android.provider.MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH I've got some results : search is working and give me results but play doesn't work.

API_COMMAND opens Poweramp but do nothing else (and I tried simple commands like play/pause).

Visual programming is quite easy to read, here is what I tried :

image.thumb.png.9e7ef1d569941c90752d3b934173cb6a.png

 

PS : I didn't see anything regarding activity class and ListActivity. Is there any other activity I can call ?

 

Link to comment
Share on other sites

  • 5 months later...

I don't know if it can be done, but right now to play a playlist I use Tasker with the following in the data field: content://com.maxmpz.audioplayer.data/playlists/##/files

Where ## is the number Poweramp assigned the playlist. I have to find this number by trial and error. It would be nice if there were an intent that would return something like an array with all the playlists names with their corresponding Poweramp ids. 

Link to comment
Share on other sites

11 hours ago, papete said:

I don't know if it can be done, but right now to play a playlist I use Tasker with the following in the data field: content://com.maxmpz.audioplayer.data/playlists/##/files

Where ## is the number Poweramp assigned the playlist. I have to find this number by trial and error. It would be nice if there were an intent that would return something like an array with all the playlists names with their corresponding Poweramp ids. 

My app shows the Poweramp id when displaying playlists in list view. I added this a while back specifically for tasker use

Link to comment
Share on other sites

1 hour ago, flyingdutchman said:

My app shows the Poweramp id when displaying playlists in list view. I added this a while back specifically for tasker use

Hello flyngdutchman, thanks a lot for your answer. What I’m looking for is a process without any human intervention. An intent to query the playlists would be sent to either your app or Poweramp, and in return Tasker would receive an array with the playlists names and probably a different intent to receive an array with the Poweramp IDs. Can I achieve this with your app?

Link to comment
Share on other sites

1 hour ago, papete said:

Hello flyngdutchman, thanks a lot for your answer. What I’m looking for is a process without any human intervention. An intent to query the playlists would be sent to either your app or Poweramp, and in return Tasker would receive an array with the playlists names and probably a different intent to receive an array with the Poweramp IDs. Can I achieve this with your app?

That functionality is not available at the moment but I can certainly write some code that will export an array with the playlist ids and/or playlist names. Send me the precise details of your requirements and I will have a look.

 

Link to comment
Share on other sites

37 minutes ago, flyingdutchman said:

@papete ias you now are able to get the Poweramp playlist id, it should be easy to create some test files with a text editor. Once you get this working, i can provide the required format

Really? Wow thanks. Tell me what should I do to get this working and/or help in the process of testing

Link to comment
Share on other sites

To play specific folder, folder id should be known or you can search by other terms (album/artist/etc) and play based on that.

Getting folder id is not a problem, as Poweramp exposes its database, but it requires querying the content provider - this is slightly out of scope of Tasker like automation and more for plugin apps.

Please check recent Poweramp API tasker readme here: https://github.com/maxmpz/powerampapi/blob/master/poweramp_api_lib/readme.md

Also, again, this post: 

 

Link to comment
Share on other sites

@papeteSo with Max's input it is clearly possible. I can get the folder_id where a track resides. Rather than me resolving the Tasker instructions, send me some screenshots of your tasker configuration. I can then try them out and determine what information is required such as playlist_id, track_id, folder_id. Below a screenshot of some of the fields available.As you can see folder_id is one of the columns

image.thumb.png.b6a0f83f0e1e421771cfd7c49fa6c9cf.png

 

 

Link to comment
Share on other sites

4 hours ago, flyingdutchman said:

@papeteSo with Max's input it is clearly possible. I can get the folder_id where a track resides. Rather than me resolving the Tasker instructions, send me some screenshots of your tasker configuration. I can then try them out and determine what information is required such as playlist_id, track_id, folder_id. Below a screenshot of some of the fields available.As you can see folder_id is one of the columns

image.thumb.png.b6a0f83f0e1e421771cfd7c49fa6c9cf.png

@flyingdutchman in my case I just need an automated way to get the playlists ID's. Ideally, I would send an intent to your app and your app would  broadcast an intent that Tasker can listen to, and receive an array or comma separated list of playlists names and id's.

For the folders, something similar could work, but it is not a priority for me. 

Also a file could be generated, it is not ideal but it would work too, as Tasker can read the file and get the info required. 

Link to comment
Share on other sites

OK, I figured out the way to get the Poweramp playlist IDs with Tasker. It only works with a rooted device: use the SQL query action. Mode: raw, file:/data/data/com.maxmpz.audioplayer/databases/folders.db Query: SELECT _id, playlist FROM playlists

This action will return an array with the playlists names and id’s. Remember to check root on the action to work.

 

Link to comment
Share on other sites

On 2/9/2020 at 2:20 PM, papete said:

OK, I figured out the way to get the Poweramp playlist IDs with Tasker. It only works with a rooted device: use the SQL query action. Mode: raw, file:/data/data/com.maxmpz.audioplayer/databases/folders.db Query: SELECT _id, playlist FROM playlists

This action will return an array with the playlists names and id’s. Remember to check root on the action to work.

 

This can also be done without root - see this reddit thread. I've checked and it works;

 

Link to comment
Share on other sites

On 2/9/2020 at 7:07 AM, flyingdutchman said:

@papete unfortunately developing integration with tasker is not a priority for me. Quiite willing to provide the necessary data if you provide the requirements.

Hi Flyingdutchman,

I see you posted a screenshot of the columns in folder_files in another thread some time ago;

Is there any easy(ish) way to find out the columns in the other tables?

What I'm trying to achieve is to get the playlist that the most recent track was played from (if any). Using Tasker I can get the name and ID of the most recently played track, and if it's only contained in one playlist then I can get the playlist that way. However, if the track is contained in more than one playlist then I can't tell which one it was played from. I'm guessing I'm missing a key to tie them together.

Link to comment
Share on other sites

On 8/15/2019 at 4:05 AM, maxmp said:

The uri would be  Data:content://com.maxmpz.audioplayer.data/folders/1

That means id is required (# == id). To know id you should query Poweramp database, etc. so it won't be easy if you want just to play something with a simple intent.

Instead I suggest using android.media.action.MEDIA_PLAY_FROM_SEARCH with free-form search text:


 Send Intent [ 
    Action:android.media.action.MEDIA_PLAY_FROM_SEARCH 
    Cat:None 
    Mime Type: 
    Data:
    Extra: query: YOUR SEARCH STRING HERE
    Extra: android.intent.extra.user_query: shuffle
    Package: com.maxmpz.audioplayer
    Class: com.maxmpz.audioplayer.ListActivity
    Target:Activity ] 

But this is API is for free format/voice search, so it can't "focus" on folders, it supports targeting on genres/artists/albums or just songs. Also, for specific shuffle mode you need to send additional command, as search query supports just shuffle (and that android.intent.extra.user_query:  depends on device system language).

Hi Max,

 

I tried this and it works, however, if I try the Poweramp API method, nothing happens. The intent I'm using is this:

 

Send Intent [ 

Action:com.maxmpz.audioplayer.API_COMMAND

Cat:None  

Mime Type: 

Data: content://com.maxmpz.audioplayer.data/search?flt= search string

Extra: cmd:20

Extra: 

Package:

Class: 

Target:Service ] 

 

What am I doing wrong?? Thanks

 

Edit: it used to work in the past with Data:content://com.maxmpz.audioplayer.data/files?flt=search string

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...