Jump to content

Updating Poweramp Rating, Last Played, Times Played. Help Needed


flyingdutchman

Recommended Posts

Any app developers out there who can help.?

In my app New Playlist Manager (http://www.playlistmanager.webspace.virginmedia.com/npm/)

, I am trying to provide a means to update specific Poweramp tags such as Rating, Times Played and Last Time Played. This will help those who migrate phones/devices and want to retain their Poweramp tags. For this to work, I have an export routine from Poweramp (old Phone/device) and also an import into Poweramp (new phone/device). Export works fine, Import I need some help as I am not sure how I can update each record. The code to parse the export file is complete apart from the code to update. 

 

Part 1 Export Poweramp details to text file works fine

 

public void export_pamp_details(Cursor crsor) throws IOException {
  int int_name = crsor.getColumnIndex(pamptrack_name);
  int int_rating = crsor.getColumnIndex(pamprating);
  int int_times_played = crsor.getColumnIndex(pamptimes_played);
  int int_last_played = crsor.getColumnIndex(pamplast_played);

  if (plist.check_folder(myfolder)) {
  try {
          myFile.createNewFile();
        } catch (Exception e) {
          Log.i(TAG, e.getMessage());
        }

FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
String line = "";

for (crsor.moveToFirst(); !crsor.isAfterLast(); crsor.moveToNext()) {
 line = "\""+crsor.getString(int_name)+"\"" + ","+"\""+crsor.getString(int_rating)+"\"" + ","+"\""+crsor.getString(int_times_played)+"\"" +  ","+"\""+crsor.getString(int_last_played)+"\""+"\n";
 myOutWriter.append(line);
 }

 try {
 crsor.close();
 myOutWriter.close();
 fOut.close();
 } catch (Exception e) {

  }
 }
}

 

Result:

"01. Cruel World.mp3","0","5","1421584583"
"02. Ultraviolence.mp3","0","2","1421588250"
"04. Brooklyn Baby.mp3","0","0","0"
"05. West Coast.mp3","0","0","0"
"06. Sad Girl.mp3","0","0","0"
 

 

 

Part 2 Import into Poweramp

 

public void import_poweramp_details(Context context) throws IOException {

// load text file
// for each line, find the track in the pamp database
// if cursor is returned then update that record

BufferedReader reader = new BufferedReader(new FileReader((String.valueOf(myFile))));
try {
 String line;
while ((line = reader.readLine()) != null) {
  String[] RowData = line.split(",");
  String name = RowData[0];
  String rating = RowData[1];
  String times_played = RowData[2];
  String last_played = RowData[3];
  String where = pamptrack_name +" =?";
  String criteria[] = {name };

  Cursor pampcursor = getthispampTrackcursor(context, where, criteria );
  if(pampcursor.moveToFirst() && pampcursor != null){
>>>>> here I have the correct track record, 

>>>>> I have all the necessary details

>>>>> How to update record??
 }
Log.i(TAG,name +rating+times_played+last_played);
}
}
catch (IOException ex) {
// handle exception
}
}
}

 

Now I know from previous posts that the api does not provide an interface to update.

A) Is this assumption still correct? 

B) is there away to achieve this update?

C) perhaps Poweramp developers can help?

Link to comment
Share on other sites

  • 4 months later...
  • 11 months later...
  • 2 years later...

Archived

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

×
×
  • Create New...