Author Topic: General Android Playlist Sync Problems  (Read 4289 times)

KangNi

  • Full Member
  • ***
  • Posts: 176
Hi there,

playlist issues seem to be a very frequent problem when it comes to sync a mobile device with MB. I'm sure there are plenty of reasons why somethings went wrong or simply doesn't work. One reason obviously is the huge variety of different devices, OS's and apps that support only different formats or simply have a very own strategy storing or handling playlists.

I decided to start a new thread here because to me it seems it could be a good way to sum up some basic knowledge about how Android devices handling playlists. So I hope this thread can keep seperate and will not be merged into a existing one.

Because I use an Android (6.0.1) device in connection with the Smasung Music App, I will focus on this setup in the following.

During testing the new MB WiFi-sync feature, I've experienced playlist sync problems again, even though it still work fine through MTP sync. So I've just started investigating and testing some things to find what's probably going wrong, respectively why my Android device has problems with synced playlists sometimes and sometimes not.


Problem 1:
Playlist files seem to be discovered totally random by a media app like Samsung Music, if copied (manually) to any folder on my device. Most times they seem to be never discovered by any music app.

Problem 2:
Playlist sync via MB WiFi-sync doesn't really work. Playlist files are transfered corretly and the Samsung Music app display them too, BUT the playlists shown in any media app are all empty - so they can't be used! To avoid any misunderstandings, the m3u files are totally intact and containing the correct paths to all media-files.


Long story shortened already :) - so far I've discovered following:

+ Android uses an own internal media scanner, which builds up a database about all you media-files and also playlists. This database should be loacted somewhere here in most cases:
 - /data/data/com.android.providers.media/databases/external-{some hex here}.db [or]
 - /data/data/com.google.android.music/databases/music.db
  I'm unsure which database is used under which condition, but that shouldn't be important here.
+ Music Apps like Samsung Music and others I suppose, just using this Android media store database.
+ Most times new files or playlists can NOT be discovered by any media app, just because the Android media scanner did NOT YET detect them!
+ I'm unsure if the Android media scanner can be triggerd by any command via MTP or which events will lead to initialize a rescan. Anyhow, the Android media scanner can be triggered MANUALLY whith apps like these here:
 "ScanMediaPlz" https://play.google.com/store/apps/details?id=net.zhuoweizhang.scanmediaplz
A few seconds later after you getting run it, you should find the playlists shown correctly in your media app, if they wasn't there before.
+ As long MB weird MTP-sync is used, the Android MTP handler always directly updates the Android media store database, so a rescan is unnecessary.
+ MB Wifi-Sync does/can? NOT use the Android MTP handler so the Android media scanner will be called by the app right after sync process is finished.


What I have observed:

+ It should not matter where the playlist files located are. However, I'm unsure how the Android media scanner deals with relative or absolute paths inside the playlist files. I've used absolute paths inside M3U files, but putting them in a subfolder and it just worked!
+ No matter if using MB wired MTP- or WiFi-sync, in both cases paylist files themselves will just be copied fine in the specified folders on your device without problems.
+ Using MB MTP-sync, MB additionaly seems to dicrectly write playlist information into the Android media store database or just trigger a media rescan automatically the Android MTP handler directly updates the media store database, because so after the sync process is finished, playlists imediatly appear correctly in my media app!
+ Using MB Wifi-sync, the Wifi Sync App seems also to dicrectly write playlist information [names only] into the Android media store database, because so after the sync process is finished, playlists imediatly appear in my media app - BUT as mentioned above, they are all empty! Under these condition a manual media rescan with "ScanMediaPlz" does NOT help. To recover this situation, I manually have to delete the playlists inside my media app (Samung Music), which in fact means, remove them from the Android media store database. After that, a manual media rescan with "ScanMediaPlz" leads to the expected result: Playlist listed corectly!


Questions and Answers Open questions and possible recommendations:

+ Is it possible for a MTP host or any Android apps like "MB Wifi Sync" to directly write into the android media store?
A: This is done by the Android MTP handler but also can be done by an Android app, and it's currently done by the MB Wifi Sync app.
+ If so, is it really neccessary to transfer the playlist-files onto the Android device too?
A: If playlist informations would be written completely into the Android media store DB it would NOT be neccesary (my understanding so far).
+ Could it be possible that the app "MB Wifi Sync" just write faulty data to the android media store, or why it just generate empty playlists and why they can not be recovered by manualy trigger the Android media scanner?
A: MB Wifi Sync currently only writes playlist names but do not write the referenced files inside of these. Due to an obvious misbehave of the Android (6.0.1) media scanner, these playlist does not became updated (my understanding so far).
+ Could "MB Wifi Sync" just trigger the Android media scanner right after finishing the sync process, if it does not already?
A: Yes, and this should happen already.


I hope, I could bring some light into the topic for a few of you.
In addition I also hope to get even more light in to that topic, by some one who can answers the questions above.

The most important goal, however, should be to make the synchronization reliable and robust for everyone. That would be awesome. :)
Wifi Sync definitely seems to be the way forward here!

Please also correct me if I made wrong statements here and there.

Thank You in advance,

Greetings


MB 3.3.7003
MB Wifi Sync 0.2.6
Android 6.0.1
Last Edit: May 30, 2021, 03:22:12 AM by KangNi

Freddy Barker

  • Sr. Member
  • ****
  • Posts: 751
  • 🎧 MB 3.4.7628P
Thanks for your research.
Fortunately i've not noticed any of the issues that you mention.
While using the latest version of MusicBee and the Music Bee WiFi App, as long as the paths on the Android device (6.0.1 for me), are correctly configured, the SD card (if selected), is granted access, then music files and playlist are synced OK.
As with wired or WiFi sync, it may be necessary to run the "Check for new or changed media" on the device music player, and this has always been the case, at least for myself...
Sorry if you've been having problems.
Regards:  Freddy

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
I can confirm with wired MTP sync, the mediastore database is updated by the android MTP handler.
And with Wireless, I have added code to call the mediascanner to do the same. However for playlists, there are a number of old and unanswered android bug reports where the mediascanner function doesnt actually update the mediastore database with the playlist. So for playlists, the Wifi Sync app directly inserts the playlist names into the database. That works fine for my purposes (and I think fine for most players) but as pointed out, the referenced files in the playlist are not written. I can also do that but it may be several days before I can look at it.

Freddy Barker

  • Sr. Member
  • ****
  • Posts: 751
  • 🎧 MB 3.4.7628P
I did discover during my testing, that although the playlists were copied to the Android device, they did look 'empty', but after hooking the device up to a PC via a cable and reading the m3u files with notepad, you could see they contained the file paths of the music files...

KangNi

  • Full Member
  • ***
  • Posts: 176
I can confirm with wired MTP sync, the mediastore database is updated by the android MTP handler.
And with Wireless, I have added code to call the mediascanner to do the same. However for playlists, there are a number of old and unanswered android bug reports where the mediascanner function doesnt actually update the mediastore database with the playlist. So for playlists, the Wifi Sync app directly inserts the playlist names into the database. That works fine for my purposes (and I think fine for most players) but as pointed out, the referenced files in the playlist are not written. I can also do that but it may be several days before I can look at it.

Thank you Steven for that clarification.

As long the MB Wifi Sync app directly writes to the Android mediastore database, it seems to be a good idea to also write referenced files inside the playlists and not only the playlist names. As I described above, in that case the Android mediascanner does not update the content of the playlist inside his database. So first the playlists have to be removed from the database, before the Android mediascanner does the job correctly. At least, this is how it works for me on Android 6.0.1. Maybe it's fixed for later Android version already?

From my view there would also be the option to NOT write to the Android mediastore, but instead to just call the mediascanner function via MB Wifi Syn right after sync process is finished. But as you pointed out, "there are a number of Android bug reports where the mediascanner function doesn't actually update the mediastore database with the playlists".
This seems to be a weird problem as long each Android version work different  :-\ .

I will just look forward now to the the announced potential changes you was mentioned above.

Greetings.
Last Edit: March 10, 2019, 02:35:09 PM by KangNi

KangNi

  • Full Member
  • ***
  • Posts: 176
I did discover during my testing, that although the playlists were copied to the Android device, they did look 'empty', but after hooking the device up to a PC via a cable and reading the m3u files with notepad, you could see they contained the file paths of the music files...

Hello Freddy,

My initial post obviously was misleading in this regard before. The M3U files and it's content are not the problem, but obviously the way how the Android media scanner handles these files, if there already exists a playlist with the same name inside the mediastore database. And exactly this is what MB Wifi Sync currently does, it just writes the playlist names, but not theirs contents.

Greetings
Last Edit: March 10, 2019, 01:33:01 PM by KangNi

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
full writing of synched playlists to the mediastore database is done for the next android app update. I will make it available after some more testing and other changes

KangNi

  • Full Member
  • ***
  • Posts: 176
Hi Steven,

thanks for your update.

I've updated to the latest version on MB Wifi Sync and MB too.
Unfortunately there is no change in behavior of how the Samsung Music App handles the synced playlists.

Playlists still shown in Samsung Music App after sync - but still empty.
Deleting them in the app and manually trigger the android media scanner does the job. After that, playlists shown correctly in Samsung Music.

So far I understand, if the playlist would NOT become written to the android MSDB, just triggering the Android media scanner after all files are synced would also help here. Of course it would take some additional time until the media scanned finishes his job, but at the moment there still somethings seems to be broken when MB Wifi Sync is writing the playlist contents into the android MSDB.

MB 3.3.7016
MB Wifi Sync 0.4.1
Android 6.0.1
Samsung Music 16.2.13.24

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
In that case i will remove the new functionality for writing playlist tracks to the database as its quite an overhead to do that and you should just use wired sync

KangNi

  • Full Member
  • ***
  • Posts: 176
Understood.

The solution - at least for the problem like i've eperienced - would be, to renounce writing anything related to playlist into the Android MSDB. At least on my configuration the Android mediascanner then would working like expected.

As you've mentioned already, to NOT write the playlist names into the MSDB ISN'T an option as well, because of this in turn is causing potential troubles on other devices.

That's a somehow frustrating issue here.  :-\

Anyhow, thank you Steven for your good will trying to solve this.

Greetings
Last Edit: March 19, 2019, 08:41:14 PM by KangNi

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
I did a comparison of how MTP wired sync updates the mediastore database and there are a couple of minor differences, so I updated the app to be consistent. I dont think it will likely make any difference but in any case if you want to try it, PM me your email you use for the play store and i will add you to the alpha testing list so you can try it out.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
Testing this with Google Play, the playlists are loading fine - I am fairly certain google play is using the mediastore database as they playlists were not previously loading in older sync app versions.
So irrespective of whether this works for the Samsung player, i will leave the functionality to update the mediastore database with playlist tracks.

KangNi

  • Full Member
  • ***
  • Posts: 176
Success !  :)  The last version of MB Wifi Sync did the trick. Playlists synced just fine and appear immediately in Samsung Music!

Congratulations and Thank You Steven!

MB 3.3.7016
MB Wifi Sync 0.4.2
Samsung Music 16.2.13.24
Android 6.0.1
SM-N9100