Tunez_Replacement main page

Player Controller

This controller contains the functionality used by the Client. It has access to the Database Controller.

Exposed Functionality

  • Vote - simply vote on songs with the given ids. Details on this schema are coming soon.
    • returns: the state of the player (see below)

Components

State

The state is returned from the vote call and can be requested by submittig a blank vote. The state contains:

  • currently playing song (and metadata)
  • the main song queue (and metadata)

Non-persistant Structures

user_queue id, user_id, title, artist, album, path, tracknum, year, length, genre, timestamp
play_queue id, user_queue_id

Scheduler

This component determines the ordering of the PlayQueue. Should be called anytime the queue changes. This includes users voting up or down on songs and anytime a song ends.

Algorithm:
The scheduler will be a fair round robin system with respect to time. This scheduler should be called anytime the queue changes (vote up, vote down, end of song, song skipped).

  • The queue is examined and divided into the different contributing users.
  • From these users, their own play queue is constructed and ordered according to time (the longer ago a song was voted, the higher it will be).
  • Now we'll construct the new play queue:
    • Choose a user using round robin. Examine this user's queue:
      • Choose the song with the highest number of votes universally.
      • If all songs have the same number of votes, choose the oldest song.
    • Remove this song from every user's queue and add it to the play queue
  • repeat until no songs are left in any user's queue.

Playing the music

python bindings for xine are available, these are what we'll use. docs can be found here: http://pyxine.sourceforge.net/readme.html

Internals

I hate wiki suckage... Here's some ideas for the internals (abridged this time)

  • Interface - handles XML, passes off to Player
  • Player - main, handles Xine, list of Users, Databases, Songs, does scheduling
  • User - netid, list of pointers to Songs in Player
  • Database - URL, dbid (probably useless)
  • Song - dbid, songid, length, votes