Music player in R (Linux)

February 26, 2012
By

(This article was first published on » R, and kindly contributed to R-bloggers)

Yesterday I found out about ‘mplayer’, which is a movie/music player for Unix that can be completely controlled from the terminal (http://www.mplayerhq.hu/). I started playing around with it while at the same time learning reference classes. The result, a music player in R!

Code

It is very basic and abit buggy (mainly in displaying unwanted warning messages) but does seem to work. The code above (requires tcltk package) gives the reference class “playlist”. First we create a new empty playlist:

pl <- playlist$new()

Next we fill the playlist by manually adding music files:

pl$add()

or by importing all music files in a folder (recursively):

pl$dir()

Both open a gui window by default, but can be supplied a character with the locations as well.

Now we can shuffle the playlist if we want:

pl$shuffle()

Finally, start playing:

pl$play()

And if we don't want to listen anymore:

pl$stop()

Furthermore 'pause' can be used to pause playing, 'skip' to skip a song, 'step' to skip multiple songs and 'previous' to go back a song.

I have only tested this on a Linux computer (Ubuntu 11.10).

To leave a comment for the author, please follow the link and comment on their blog: » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Mango solutions



RStudio homepage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training

datasociety

http://www.eoda.de





ODSC

ODSC

CRC R books series





Six Sigma Online Training









Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)