So the Samsung Galaxy S III has an MP3 player as an accessory to let you take a smaller music player than your huge phone with you when you work out and things like that. Big whoop. In this article I’m going to show you how you can get any MSC enabled player to sync to practically any USB-host enabled Android device in a way that makes the S Pebble look like it’s not just the name that’s related to the stone age. With devices such as a the Sansa Clip series out there that are still amazing music players, this new role as an accessory to a smartphone/tablet might help the MP3 player market stay alive.
What you need to make this work is an MP3 player that can work in MSC/UMS (aka plug-and-play file transfer) mode, an Android device that has a USB host port (most high end devices supports this via adapters), and an Android app called Tasker ($6.50) . Tasker is an automation app that allows you to do some ridiculous things when it comes to automation, from switch off WiFi when you leave the house to control your home automation system based on where you are. It works on a “if this happens, do that” principle, but unlike services like ifttt.com or even many similar automation apps, Tasker is much more advanced.
As for the Android device, there is a potential issue you can run into with regards to a connected device’s power requirements. My Galaxy S II can host a Sansa Clip Plus directly, while my Galaxy Tab 7.0 Plus gives a high powered device error. If that happens, you basically need to either have a powered USB hub in between, or use a split USB cable with an extra cable for power, and hook that into a charger of some kind – external USB batteries work for that too, for a portable solution. This depends on both the MP3 player and the Android device though, so you’ll just have to test and see.
Be aware that Tasker is considered by many to be too complicated for its own good. Even though I’m giving you a profile that can be imported directly into Tasker, some things may have to be edited to make it work on your specific device, and bugs and errors might occur that I haven’t encountered. In other word, proceed at your own risk – or perhaps more specifically risk of wasting time.
Start by downloading this file. If you open the link from an Android device with Tasker installed, it should automatically ask you if you want to import the profile into Tasker, which you do. When it’s in there, you should have a profile called Sync-advanced. The following is an explanation of what everything in that profile does. You will need to read that and make any necessary changes before the profile will do you any good.
Update: I forgot to mention that you need to enable Tasker in your device’s accessibility settings. These can be found in the main device settings. You also need to make sure Tasker isn’t in beginner mode, which you do by clicking the menu button, Preferences, UI tab, and remove the checkmark from Beginner Mode
Update: Video walkthrough
This video should make it easier to understand how to modify the profile for other devices. I’ll leave my original text explanation below in order to provide a full rundown of what does what in this profile, as the principles used here can be used for other things if you learn how it works.
Context: Notification, USB device connected
This is the profile’s trigger, the event that makes the tasks run. It’s set to trigger on a system notification called “USB device connected”, which is when you insert a USB device. If your device has a different message when USB host is being used, you need to change this.
This is the task that runs when the profile is triggered. It contains 16 actions, which are as follows:
1. Variable Set
Variables in tasker are part settings, part text files that aren’t saved anywhere. A variable can store different data to be used across tasks and profiles, and this profile uses a variable I’ve named %USBidentifier (the % in front signifies it’s a variable) which contains the name of the connected device. This is needed to make sure that Tasker doesn’t start copying files to just any USB device, only “registered” MP3 players that you want to have synced. This very first actions simple sets the USBidentifier variable to “na” in order to reset it from last time a device was connected, just in case the connected device can’t be identified (more on this later).
This simply makes Tasker wait 10 seconds before proceeding in order to let the connected device mount in peace and be scanned for media by the Android device.
3. Read File
To Var: %USBidentifier
In order to identify a connected device, a simple text file has to be placed in the root directory of the device. The textfile needs to be called Identifier.txt and simply contain the name of the device. In this case, “Sansa Clip Plus”, this text is what will be used for the voice messages as well as to identify it as an MP3 player. The way this profile is set up, you should only add these files to actual MP3 players, leaving any other device “unidentified”. This is because it’s currently set up to sync to any device that has an identifier. This can be changed if you know how, but for the purpose of this rundown, it’s not needed.
Note that this is the first of several actions that refers to a specific file path. On my Galaxy S II, the root directory of a connected USB device is usbStorage/sda/, meaning that if the root directory for a connected device is different on your device, this path has to be changed in all actions that use it.
If: %USBidentifier ~(matches) na
Stops the task if the USB device is not identified. Simply means nothing will happen if Identifier.txt is not located.
This uses text to speech to say “%USBidentifier connected”. %USBidentifier will be switched out with the contents of Identifier.txt, so for a Sansa Clip Plus with an Identifier.txt that says “Sansa Clip Plus”, you will get “Sansa Clip Plus connected” like in the video. This can be removed if found annoying, or it can be replaced with e.g. the Flash action under Alerts, which simply displays a text message on the screen instead.
6. Variable Set
This resets a the counter variable which allows us to count how many files were copied.
7. Variable Set
Same as above, but for number of skipped files.
8. List Files
Dir here needs to point to wherever you want to copy music from. In my case, that’s the Music folder on the external SD. Chances are yours won’t match the path exactly.
What this does is to read all the files in the directory and create separate variables for them with the prefix %sourcefilelist. As an example, the path to file number 6 in that directory will be stored in %sourcefilelist6.
9. List Files
Same as above, but for the target directory. Dir needs to point to where you want to put the music, meaning somewhere on the connected device. In my case, in the Music folder on the player. Note that if you want it to copy files to a folder on the root directory and not the root directory itself, the folder needs to exist before you connect the device. If you’re copying to the root directory, that’s not an issue.
Update: Also, this directory has to have loose files and no sub folders. If you want to use sub folders, you either have to modify the task accordingly (very advanced) or use the method that copies the entire directory, described further down.
This action signifies that you’re starting a repeating action. Any actions that are nested within this (number 11-14) will run over and over for each file in the source directory. Nothing needs to be changed here assuming you’re keeping with my variable names.
Type: File Name
Store Results In: %sourcefilename
This converts the file path from the source file list into a file name. Nothing needs changing.
12. Copy File
If: %targetfilelist() !~ (doesn’t match) *%sourcefilename*
Copies the file if the file doesn’t already exist on the target device. the To: field needs to be changed to where you want the music stored (same as in 9). The From field will automatically be correct as long as number 8 is set up correctly.
13. Variable Add
If: %targetfilelist() !~ *%sourcefilename*
Part of the copied/skipped counter. If a file is copied, it adds 1 to the counter.
14. Variable Add
If: %targetfilelist() ~ *%sourcefilename*
Same as above, but adds 1 to the skipped counter if a file is not copied.
15. End For
Simply ends the loop once all the files have been checked.
Text: Finished copying %copied files to %USBidentifier. %skipped files already existed
Once everything is done, this lets you know how many files were copied and skipped. Can be deleted or replaced like number 5
To make it faster
Deleting (by dragging the icon down to the trash bin that appears) number 6, 7, 13 and 14 will speed up the process by disabling the counter. You’ll then need to remove the counter bits from number 16 or it will say the name of the variable instead.
To make it simpler/overwrite files
If you want to make this simpler, or want a version that overwrites files in order to update ID3 tags etc, you can do the following:
- Delete actions 6-15
- Add an action after number 5 that uses the Copy Dir feature under File. Select which folder to copy and where to copy it. I think the Copy Dir is only available on the latest beta versions of Tasker, meaning that you have to replace the Google Play bought version with the market version here without uninstalling the former first. Don’t worry though, the beta is just as stable for these types of things.
- Edit the former action 15, now action 7, and remove the counter references.
This will make it always overwrite files, create directories as needed, as well as make it easier to Tasker beginners to get a grip on. It is however increasingly slower the more music you’re copying, because it’s copying all of it every time.
I’m always rather hesitant at sharing my Tasker creations on non-Tasker sites because it can confuse the living soul out of people – with good reason. The thing about Tasker is that it’s complicated to set up, but once it is set up, you’ll reap the befits in full. I have profiles that are many times as complicated as this that I set up months ago, and while I don’t really remember how they work at this point, they do. Unfortunately the first MP3 player related task I’ve ever done is this one, which is why it’s the first mention of Tasker on this site. Ideally it would have been a gradual thing leading up to this, but the world doesn’t always work that way. The video at the top shows the profile in action, running completely in the background and triggering on a USB connection. As you can see it’s as automated as music sync can be once set up, but unfortunately that means that actually setting it up is a bit complicated.