Jump to content

How to Update the Poweramp Playlist in android


flyingdutchman

Recommended Posts

 

I am trying to update the Poweramp Playlist from an android playlist.

I have

  • the Poweramp database structure

  • Poweramp content:// uris to select from

  • managed to complete the first step which is to add the new android playlist name into the Poweramp playlist table.

  • the actual file name of the track

  • verified that the Poweramp unlock license is installed as it seems that this is what unlocks the dataprovider for Poweramp

I need to obtain:

  • the track_number by querying the folder_files table

update: 2/8/13. removed most of this post as it was irrelevant. Question is valid though and I think I now have my answer :(

 

 

  • 2 weeks later...

It looks like I have to abandon this piece of functionality. It would have been a nice addition to my "Playlist Manager" and I am sure would have been appreciated by all Poweramp users.

You can find my app on Google market. Search for Playlist Manager by THEOKLINK.

If I do get some help with this, I will add the "Android to Poweramp" playlist export functionality.

 

ps I just need to be able to READ from the folder_files table to return the _id as I need this to create a new playlist in folder_playlist_entries

  • 2 weeks later...

Please check the Samples API for the URIs. The URI "root" is: PowerampAPI.ROOT_URI => content://com.maxmpz.audioplayer.data

The following playlist related uris are implemented for "update", "delete" db actions:

content://com.maxmpz.audioplayer.data/playlists

content://com.maxmpz.audioplayer.data/playlists/ID/files

 

"insert" db action:

content://com.maxmpz.audioplayer.data/playlists

 

You can't add playlist entries currently via API. If you need this functionality - we can add it to the next builds.

Also, you can just generate and update m3u8 files in /Playlists (or actually, any other accessible by Poweramp folder) - Poweramp will show those as file based playlists. Note that only songs which are in Poweramp accessible folders will be shown in such playlists.

 

Thanks!

  • 4 weeks later...

As no one has responded perhaps I need to simplify my question:

 

"how do I query the Poweramp database and return the track_id"

 

Update: Nov 13; my "Playlist Manager" app by THEOKLINK on Google Play checks if Poweramp is installed on your device. If it is, it offers you mp3 tags from Poweramp so you can create playlists outside Poweramp but still use tags such as ratings. An m3u export function also allows you to play these android playlists in Poweramp. The user manual available in the app provided detailed information on how to set this up.

:)

  • 1 month later...

 

As no one has responded perhaps I need to simplify my question:

 

"how do I query the Poweramp database and return the track_id"

:)

try something like this:
 
mContext.getContentResolver().query(
                PowerAMPiAPI.ROOT_URI.buildUpon().appendEncodedPath("files").build(), new String[] { "_id" }, null, null, null);
 

 

  • 3 weeks later...

Dsaran,

your tip has helped me enormously. As I am an android newby, I now realise that the first step is to include the Poweramp library. Once I understood this, I have been able to query the tables using variations of the above uri.

However, I have come unstuck again as I now understand what maxmp means by

 

"You can't add playlist entries currently via API. If you need this functionality - we can add it to the next builds."

 

It would be great if this functionality could be added to the next release. I am developing a Playlist Manager for Poweramp similar to the one I have for native android on Google Market (search for "Playlist Manager" by THEOKLINK)

As my app exports native playlists to m3u format, I have even provided a user guide with screenshots on how to set Poweramp up to scan folders for m3u playlists.

 

If anyone has other suggestions, please let me know.

Thanks

  • 3 weeks later...

For those who are interested:

Although it is not possible to update the Poweramp playlist, I did manage to interrogate the database and return values

In its simplest form:

final String pamptrack_id = "folder_files._id";

final String pamptrack_no = "folder_files.track_number";

final String pamptrack_name = "folder_files.name";

final String pampartist = "artists.artist";

final String pampduration = "folder_files.duration";

final String pampalbum = "albums.album";

final String pampyear = "folder_files.year";

final String pamppath = "folders.path";

final String pamprating = "folder_files.rating";

final String pamptimes_played = "folder_files.played_times";

final String pamplast_played = "folder_files.played_at";

final Uri uri = Uri.parse("content://com.maxmpz.audioplayer.data/files");

 

 

public Cursor getpampTrackTrackcursor(Context context, Cursor cursor)

{

// gets all tracks

ContentResolver cr = context.getContentResolver();

String[] proj ={ pamptrack_id, pamprating,pamptimes_played, pamplast_played };

cursor = cr.query(uri,proj,null,null,null);

return cursor;

}

 

go

https://play.google.com/store/apps/details?id=com.flyingdutchman.playlistmanager&hl=en

to see this is action

  • 5 months later...

Please check the Samples API for the URIs. The URI "root" is: PowerampAPI.ROOT_URI => content://com.maxmpz.audioplayer.data

The following playlist related uris are implemented for "update", "delete" db actions:

content://com.maxmpz.audioplayer.data/playlists

content://com.maxmpz.audioplayer.data/playlists/ID/files

"insert" db action:

content://com.maxmpz.audioplayer.data/playlists

You can't add playlist entries currently via API. If you need this functionality - we can add it to the next builds.

Also, you can just generate and update m3u8 files in /Playlists (or actually, any other accessible by Poweramp folder) - Poweramp will show those as file based playlists. Note that only songs which are in Poweramp accessible folders will be shown in such playlists.

Thanks!

The problem is that not all URIs are writeable (insertable/deletable/etc) from available API provider - Poweramp internally don't use content provider API, so only few "verbs" are implemented. We will certanly add all the missing parts in upcoming Poweramp v3.

Thanks!

  • 2 years later...

A few years on an a little more android/java savvy and re-reading Max's responses, I have added the Poweramp Playlists to my app New Playlist Manager (NPM).

Functionality at the moment :

- list Poweramp Playlists in NPM (including the .m3u types)

- Play a playlist directly from the NPM app

- simple click and play a track

- Maintain albumart and mp3 tags for track, album or selection of tracks

The next release will allow you to delete Poweramp Playlists from NPM.

Hopefully the next release of Poweramp will allow me to add all other functionality generally available in NPM .

As Max states "  We will certainly add all the missing parts in upcoming Poweramp v3 "

Keeping my fingers crossed !!!

On 02/08/2013 at 4:27 PM, TheoKlink said:

Dsaran,

your tip has helped me enormously. As I am an android newby, I now realise that the first step is to include the Poweramp library. Once I understood this, I have been able to query the tables using variations of the above uri.

However, I have come unstuck again as I now understand what maxmp means by

 

"You can't add playlist entries currently via API. If you need this functionality - we can add it to the next builds."

 

It would be great if this functionality could be added to the next release. I am developing a Playlist Manager for Poweramp similar to the one I have for native android on Google Market (search for "Playlist Manager" by THEOKLINK)

As my app exports native playlists to m3u format, I have even provided a user guide with screenshots on how to set Poweramp up to scan folders for m3u playlists.

 

If anyone has other suggestions, please let me know.

Thanks

 

In this thread Max states 

On 2/1/2014 at 5:33 AM, fullahead said:

You can't add playlist entries currently via API. If you need this functionality - we can add it to the next builds.

but somewhere else he states

http://forum.powerampapp.com/index.php?/topic/3644-changing-playlist-content/#comment-14466

Thus to insert track into Poweramp list you need:

1. have it under Poweramp available folders (there should be entries for the track in folder_files table)

2. insert appropriate folder_files._id into playlists table."

The statements seems to contradict. Perhaps Max can clarify?

Anyway, at the moment I am stuck on trying to add playlist entries (so perhaps the first statement is correct)

Below the stacktrace errors when trying different uri's

Adding and deletion of a playlist works fine.
Next step is to add to folder_playlist_entries but am unable to find the correct uri.
I have tried all playlist uris as provided in the Poweramp API but have been unable to complete the updates

Case1
uri=        Uri uri = PowerampAPI.ROOT_URI.buildUpon()
                .appendEncodedPath("playlists")
        .build()
07-30 05:11:08.111 1814-2106/com.maxmpz.audioplayer E/SQLiteLog: (1) table folder_playlists has no column named folder_file_id
07-30 05:11:08.111 1814-2106/com.maxmpz.audioplayer E/SQLiteDatabase: 
Error inserting folder_file_id=88 playlist_id=3 sort=7
android.database.sqlite.SQLiteException: table folder_playlists has no column named folder_file_id (code 1): , 
while compiling: INSERT INTO folder_playlists(folder_file_id,playlist_id,sort) VALUES (?,?,?)

Case 2
        Uri uri = PowerampAPI.ROOT_URI.buildUpon()
                .appendEncodedPath("playlists")
                .appendEncodedPath("files")
                .build();
 java.lang.IllegalArgumentException: Unknown URI content://com.maxmpz.audioplayer.data/playlists/files

Case 3
        Uri uri = PowerampAPI.ROOT_URI.buildUpon()
                .appendEncodedPath("playlists")
                .appendEncodedPath(Long.toString(playlist_id))
                .appendEncodedPath("files")
                .build();
java.lang.IllegalArgumentException: Unknown URI content://com.maxmpz.audioplayer.data/playlists/3/files

 

Can anyone help ??

 

 

  • 3 weeks later...

I guess the only person to respond to this would be Max or Magadaner. If the current api does not have the correct uri to update  folder_playlist_entries , would it be possible to release an interim api update? (given that the release date for the new version is unknown)

In the meantime, I remain hopeful of a positive outcome.

  • 1 month later...

I guess the only person to respond to this would be Max or Magadaner. If the current api does not have the correct uri to update  folder_playlist_entries , would it be possible to release an interim api update? (given that the release date for the new version is unknown)

any luck with this?

  • 1 month later...

@TheoKlink, do you think you could provide some guidance?  I was able to import the library doing import com.maxmpz.Poweramp.player.PowerampAPI; but now I think I've hit the same issue that you have... I can't actually query the table, but I think that's because I'm passing the wrong column ID... not sure what the column name is.

        final String idKey = MediaStore.Audio.Playlists._ID;
        final String nameKey = MediaStore.Audio.Playlists.NAME;
        final String[] columns = { idKey, nameKey };  // I think I'm using the wrong column names here... what should I use?
		// Getting the playlists here works though, and I can display them in a ListView
        final Cursor playLists = resolver.query(PowerampAPI.ROOT_URI.buildUpon().appendEncodedPath("playlists").build(), columns, null, null, null);

...

    public Uri getPlaylistUri() {
        return PowerampAPI.ROOT_URI.buildUpon().appendEncodedPath("playlists").appendEncodedPath(Long.toString(getPlaylistId())).build();
    }

    public Cursor createPlaylistCursor(String sort) {
        Log.d("BLAH", getPlaylistUri().toString());  // this looks like it logs the proper path "content://com.maxmpz.audioplayer.data/playlists/8"
        return getContentResolver().query(getPlaylistUri(), null, null, null, sort);  // This crashes the app with Unknown URI content://com.maxmpz.audioplayer.data/playlists/8
    }

 

First off, Poweramp has its own database so querying the android database is pointless. You must use the column names as held in the Poweramp database. To get the database, use Android Device Monitor in Android Studio and pull it to your pc. It is data/data/com.maxmpz.audiplayer/databases/folders.db 

The way I went about this is use an sql tool on my pc (Razorsql) (or on android) and open the Poweramp database. You will see the structure and the column names. The next thing then is to figure out which uri to use. You can find the uris listed in the Poweramp API. Each uri gives access to certain tables and returns data from them. As these uris are a bit of black art, I tended to add an invalid column name so it would crash. The stacktrace then gives you clues as to what it is trying to do.

// SELECT folder_files._id, folder_files.name AS name,
// folder_files.artist_id AS artist_id,duration, rating, artists.artist,
// albums.album, folders.path FROM folder_files
// INNER JOIN folders ON folders._id=folder_id
// LEFT JOIN albums ON albums._id=folder_files.album_id
// LEFT JOIN artists ON artists._id=folder_files.artist_id
// WHERE (folder_files.cue_folder_id IS NULL)
// ORDER BY folder_files.title_tag COLLATE NOCASE

See the attached screenshot as an example of folder_files.

To get all Poweramp playlists

public Cursor getPowerampPlaylists(Context context) {
    final String criteria = null;
    ContentResolver cr = context.getContentResolver();
    String[] columns = {"_id", "folder_playlists.name"};
    return cr.query(Uri.parse("content://com.maxmpz.audioplayer.data/playlists"), columns, criteria, null, "name ASC");
}

I hope this gets you going

powerampdatabase.png

  • 10 months later...

Hi everyone,

I was thinking of developing a very small app for use with Poweramp, the main feature of which would have been to add the track you are currently listening to to a playlist quickly. This seems to currently be impossible judging from this thread, however these posts seem to be rather old - Have you guys found a way or is it still a feature for developers which has yet do be added?

  • 3 months later...
  • 4 weeks later...

For the benefit of programmers interested:

To delete tracks from a playlist:

public void deleteTrackOnPowerampPlaylist(Context context,long playlist_id, String id     ) {
    Uri uri = PowerampAPI.ROOT_URI.buildUpon()
            .appendEncodedPath("playlists")
            .appendEncodedPath(Long.toString( playlist_id))
            .appendEncodedPath("files")
            .build();

    ContentResolver resolver = context.getContentResolver();
    String where = pampfolder_playlist_entries_id +" =?";
    // id is the id of folder_playlist_entries
    String selectionArgs[]={id};
    resolver.delete(uri, where,selectionArgs);
}

 

Move a track on  the playlist by changing its sort order

public void updatePositionOnPowerampPlaylist(Context context,long playlist_id, String id,
                                        int to) {
    Uri uri = PowerampAPI.ROOT_URI.buildUpon()
            .appendEncodedPath("playlists")
            .appendEncodedPath(Long.toString( playlist_id))
            .appendEncodedPath("files")
            .build();
    ContentResolver resolver = context.getContentResolver();
    ContentValues values = new ContentValues();
    values.put("sort",to);
    String where = pampfolder_playlist_entries_id +" =?";
    String selectionArgs[]={id};
    resolver.update(uri, values, where,selectionArgs);
}

Inserting into folder_playlist_entries is at the moment not possible.

Update: after v795, ALL FUNCTIONALITY  is available. I have updated my app accordingly

 

 

Archived

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

×
×
  • Create New...