Posted by Роман on March 31, 2012

Remove/delete song by pressing headset button on Android

Posted under Phone

When I listen to music during my workouts, sometimes a song comes up which I don’t like. I can press a headset button to skip it, but really I’d like to delete it forever. So far I haven’t found a single music player which allows to remove song by pressing headset button.

Turns out it is possible with Tasker and (Headset Button Controller or Headset Droid) and rooted phone.

  1. Create a Tasker task “Move song” by clicking button with “lightning”. Add action “Misc – Run shell”.
  2. In “Command” field paste: mv  "$(lsof -p $(pidof mediaserver) | grep -m 1 MY/music/ | awk '{print substr($0, index($0,$9))}')" /sdcard/trash/
  3. “Use Root” must be checked.
  4. In you headset control app bind Tasker task “Move song” to a single/double/etc.  click.

“MY/music/” is a substring of the full path to my music folder. You can change it to “mp3” or substring of you music path.

/sdcard/trash/ target folder for music I decided to delete.

More about How to find a song currently playing