I was asked by a user (thank you, Dan) to add playlist support to IR: play one song, then another, and so on. However, I didn’t want to do this. The whole idea of IR is to keep things simple, and allow users to control playback (and hence get the behaviour they want) via external apps such as Tasker.


This page describes how implement playlists for IR, but without extending IR itself.

The approach is to write a shell script (which is called by Tasker) to launch the next track when the current track finishes.


First: A Tasker Project


  1. download this Tasker project and copy it to your Tasker project directory (/sdcard/Tasker/projects); then

  2. using Tasker, import the project (IR_Playlist.prj.xml).

The project won’t do much yet, but take a look around. Eventually, you will have to edit the example tasks such that they reference suitable paths for your system.

You do not need to make any changes to the other task or the IR State profile.

Next: A Shell Script


  1. create a directory /sdcard/intent_radio, and

  2. download this shell script and copy it to that directory
    (so, to /sdcard/intent_radio/playlist).

The name of the directory (/sdcard/intent_radio) and the name of the script (playlist) matter; they’re used in the sample Tasker project.


Only run this shell script from within Tasker. Do not run it manually. (Otherwise, the state file it creates will end up being owned by the wrong user — I think).

Finally: Give it a Go

The Tasker project includes a Task IRP Playlist Play. All this does, is call the shell script above with suitable arguments. In the sample project, it’s:

sh /sdcard/intent_radio/playlist start /sdcard/xy.m3u

Change the last part, the playlist file, to your own playlist (subject to the rules, below), and give it a go.

You can also provide a directory name:

sh /sdcard/intent_radio/playlist start /sdcard/Music/Yes/Tormato

In this case, all audio files in or under /sdcard/Music/Yes/Tormato will be added to the playlist.

If you provide multiple arguments after start, then they are joined together (with spaces) and treated as a single thing.

sh /sdcard/intent_radio/playlist start /sdcard/Music/Yes/The Yes Album

This will be treated as a single directory (with spaces in its name).


The argument to start is not a URL. It is the absolute path of a playlist file, a directory, or an audio file.

Playlist files

Roughly, the supported playlist format is M3U:

  • Playlist file names must end with the extension .m3u (all lower case).

  • Empty lines and lines on which the first non-whitespace character is # are ignored.

Playlist entries

Entries beginning file://, http://, https:// or content:// are appended verbatim to the active playlist. Any necessary URL encoding must already have been applied.

Don’t use file:// for local files. If sed is available, then the playlist script handles URL encoding itself.


Every audio file and the contents of every playlist file in or under the indicated directory are appended to the active playlist. Directory names can be either relative or absolute, and should not be URL encoded.

Audio Files

The audio file is appended to the active playlist. File names can be either relative or absolute, and should not be URL encoded.

Other playlist files

The contents of the playlist are appended to the active playlist, recursively. Playlist file names can be either relative or absolute, and should not be URL encoded.


If you have existing M3U playlists which use relative paths, then there’s a good chance that they will just work.

It’s easy to generate playlist files with standard Unix utilities (if you have them). Here are a couple of examples:

Create a playlist with absolute file names:

find /sdcard/Music/Yes/Tormato -type f -name '*.mp3' /sdcard/tormato.m3u

Create a playlist with relative file names:

cd /sdcard/Music/Yes/Tormato
ls *.mp3 > Tormato.m3u
Techy tips

Take a look at the shell script itself and you’ll get a better idea of what’s going on. The shell script leaves a log of its runs in:

  • /sdcard/Tasker/.intent_radio/log.txt

The state file itself is:

  • /sdcard/Tasker/.intent_radio/state.txt

(Yes, those are a leading dots in those file names.)


The shell script supports the following options.

  • start [-l] [-r] THING

THING is the absolute path of a playlist file, directory or audio file.

If -l is provided, then the playlist is looped. If -r is provided, then the playlist is randomized.

Note, however, that randomization is only possible if you have sort on your device. Which probably means you have to have busybox installed. Which probably means you need root.

Duplicate items encountered are silently discarded.

  • append THING

Like start, but appends to an existing playlist. Also advances to the next track. append does not support the -l and -r options.

New items will not be added to the playlist if they are already on the playlist.

  • next

Move on to the next item on the playlist. If the playlist is stopped, then it is resumed.

  • stop

Suspend the playlist.


Do not use this option manually. It is generated automatically when the Tasker project receives the stop state from the player.

Also, stop, here, does not actually stop playback. It just disables the playlist.

How does it work?

IR broadcasts its state. The IR State profile in the sample Tasker project listens for these broadcasts and forwards them to the playlist shell script.

When the shell script sees a completed state, it fires off the next track. When it sees a stop state, it suspends the active playlist (so that subsequently, when a non-playlist track completes, it does not incorrectly fire off the next track on the active playlist).