Bemix Notes

From SlugWiki
Revision as of 02:59, 16 January 2006 by Rob (Talk) (Player)

Jump to: navigation, search

Bemix is a web-based media player. It supports multiple soundcards and various networked client types, allowing a group to use a centralized server to control several speakers. Commands are issued through URLs, where the URL portion of the address represents the command to be issued, while the GET portion of the URL passes in parameters to the server. Media is played via mplayer, enabling any media format to be played provided it is supported in mplayer.


Bemix requires python2.3, mplayer, and an instance of MySQL server running on the local machine to function properly. The MySQL server must contain a "bemix" database with tables "playlist" and "track." The server is designed to serve HTTP requests over port 8080.

The playlist table schema:

| Field      | Type         | Null | Key | Default | Extra          |
| playlistId | int(11)      |      | PRI | NULL    | auto_increment |
| name       | varchar(100) |      |     |         |                |

The track table schama:

| Field       | Type    | Null | Key | Default | Extra          |
| trackId     | int(11) |      | PRI | NULL    | auto_increment |
| playlistId  | int(11) |      |     | 0       |                |
| trackNumber | int(11) |      |     | 0       |                |
| file        | text    | YES  |     | NULL    |                |


All commands are send as URLs with information passed in the GET portion. All URLs are relative to, and all URLs have an output=[html, client]. An example URL is All x, y, ... must be properly encoded for URLs.


A player represents a single soundcard. There is one player for every set of speakers that the bemix server controls. Before anything can be played on a player, a playlist must be created, filled with songs, and loaded on the player.

  • play?playerId=x
  • pause?playerId=x
  • stop?playerId=x
  • loadList?playerId=x&playlistId=y
  • next?playerId=x
  • previous?playerId=x
  • player?playerId=x


A playlist consists of a name and music files that are associated with it. The songs in a playlist are ordered with indices starting at 0. Before anything can be played, a playlist must be created and loaded onto a specific player.

  • create?name=x
  • delete?playlistId=x
  • add?playlistId=x&song=y
  • remove?playlistId=x&index=y
  • playlist?playlistId=x


These commands are used to navigate the filesystem on the server to determine which files are available for playing. All operations on files and directories are relative to the server's root music directory, so /A/Air may actually refer to /mnt/tunes/A/Air on the server.

  • browse?dir=x (returns directories and files that exist at relative path x)


These commands query the bemix server for generalized information about the state of the entire system.

  • players (lists all playerIds available)
  • playlists (lists all playlistIds available)


Each command returns a data structure through HTTP that defines variable names and values. A (variable name, value) combination is referred to as a field. Every command contains at least one success field, whose value may be either true or false. If any tag is false, it should be assumed that the entire command failed. Each command may optionally return a comment field as well, whose value gives some indication of why an operation may have failed.

In addition, most commands return additional information about the state of a particular aspect of the bemix server.

Client Types

Bemix is capable of dumping data in multiple of formats. Currently only the "client" and "html" formats are planned, but XML/RDF formats are possibility in the future. The format of the export is indicated in the URL by the mandatory output parameter.


The "client" output format returns data in a simple newline-delimited list. String values are not delimited by quote characters, and list items are delimited by commas (including a comma after the final element). The format of each line is name=value, where name is the name of the variable being returned, and value is the value of the variable. No whitespace characters are inserted between name, =, and value.

The order in which the fields are returned is not guaranteed, and it should not be assumed that all tags will be present or in any particular order.

The MIME type of the client output is 'text/plain'.

The result of the browse command

dir0=/P/Porcupine Tree/Coma Divine
dir1=/P/Porcupine Tree/Spiral Circus
dir2=/P/Porcupine Tree/In Absentia
dir3=/P/Porcupine Tree/Insignificance
dir4=/P/Porcupine Tree/Lightbulb Sun
dir5=/P/Porcupine Tree/Metanoia
dir6=/P/Porcupine Tree/On the Sunday of Life
dir7=/P/Porcupine Tree/Recordings
file0=/P/Porcupine Tree/Chloroform (Instrumental Rough Mix).mp3
file1=/P/Porcupine Tree/Disappear (Demo Version 2.0).mp3
file2=/P/Porcupine Tree/Is Not.mp3
file3=/P/Porcupine Tree/2003 Intro Music.mp3
file4=/P/Porcupine Tree/Even Less, Part 2.mp3
file5=/P/Porcupine Tree/London.mp3

The result of the playlists command


The result of the players command with an invalid playerId

comment=playerId not found


When dumping data as HTML, bemix creates pages that can also be used to issue commands to the server. For instance, a browse page generates a link for each directory that is being displayed that points to the browse page for that subdirectory.

HTML output is meant to be used through a webbrowser. If you're interested in manipulating the bemix server through some other means, use the "client" output format described above.

See Also