<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ArvinderKang.com &#187; mp3 player</title>
	<atom:link href="http://arvinderkang.com/tag/mp3-player/feed/" rel="self" type="application/rss+xml" />
	<link>http://arvinderkang.com</link>
	<description>The world is my backyard.</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:58:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Jukebox in a single line</title>
		<link>http://arvinderkang.com/2008/06/28/jukebox-in-a-single-line/</link>
		<comments>http://arvinderkang.com/2008/06/28/jukebox-in-a-single-line/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 04:05:34 +0000</pubDate>
		<dc:creator>Arvinder Kang</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[jukebox]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[mp3 player]]></category>
		<category><![CDATA[one]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[single]]></category>

		<guid isPermaLink="false">http://arvinderkang.com/2008/06/29/jukebox-in-a-single-line/</guid>
		<description><![CDATA[If you are like me, who starts starts iTunes with default library and realize you have heard the same song 8 times in the last week, here are two one-line-Jukebox scripts for you. The scripts randomly choose and play songs &#8230; <a href="http://arvinderkang.com/2008/06/28/jukebox-in-a-single-line/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are like me, who starts starts iTunes with default library and  realize you have heard the same song 8 times in the last week, here are two one-line-Jukebox scripts for you. The scripts randomly choose and play songs right from the command line.</p>

<p>Before using the script make sure you have an mp3 player installed. <a href="http://arvinderkang.com/2008/06/28/installing-command-line-mp3-player/" title="Installing command line MP3 player | ArvinderKang.com">I have installed lightweight mpg123</a>, however you can use any player. I would recommend <a href="http://www.mplayerhq.hu/" title="Entering MPlayer homepage">mplayer</a> for Linux.</p>

<p>While running the scripts, I pass ~/Music folder argument. Change the path to point to folder where you store your mp3s.</p>

<p>First one is in <a href="http://www.ruby-lang.org/" title="Ruby Programming Language">Ruby</a>, and shamelessly inspired by <a href="http://www.amazon.com/Ruby-Example-Concepts-Kevin-Baird/dp/1593271484" title="Amazon.com: Ruby by Example: Concepts and Code: Kevin Baird: Books">Kevin Baird&#8217;s book</a>.</p>

<p>Open a text editor and save this script. I named it shuffle_play.rb. (You need to have ruby installed on your system. Installed on Leopard and most Linux distributions by default.)</p>

<pre><code>#!/usr/bin/env ruby -w
ARGV.sort_by{ rand }.each {|file| system("mpg123 \"#{file}\"")}
</code></pre>

<p>To run the jukebox</p>

<pre><code>ruby shuffle_play.rb ~/Music/*.mp3
</code></pre>

<p>For the second, I ported above  script to bash, which is even more simple and can run on any Linux or OS X. Lets name the script shuffle&#95;play&#95;shell.sh</p>

<pre><code>#!/usr/bin/env bash
n=0;for songs in "$@" ; do song_array[n]=$songs ;((n++)) ; done; for ((i=0;i&lt;$n;i+=1));do number=$RANDOM; let "number %= $n"; `mpg123 "${song_array[number]}"`; done
</code></pre>

<p>To run the jukebox</p>

<pre><code>source shuffle_play_shell.sh ~/Music/*.mp3
</code></pre>

<p><em>Update</em>: The second one is not completely random. It will choose n random songs out of n songs. However it does not checks if each song is played at-least once, thus chances of songs getting repeated. Any suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://arvinderkang.com/2008/06/28/jukebox-in-a-single-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing command line MP3 player</title>
		<link>http://arvinderkang.com/2008/06/28/installing-command-line-mp3-player/</link>
		<comments>http://arvinderkang.com/2008/06/28/installing-command-line-mp3-player/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 11:28:23 +0000</pubDate>
		<dc:creator>Arvinder Kang</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[mp3 player]]></category>
		<category><![CDATA[mpg123]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://arvinderkang.com/2008/06/29/installing-command-line-mp3-player/</guid>
		<description><![CDATA[mpg123 is a real time MPEG 1.0/2.0/2.5 audio player for layers 1,2 and 3. I was playing with Ruby scripts and needed a command line mp3 player which was not a resource hog. Steps I took for my OS X &#8230; <a href="http://arvinderkang.com/2008/06/28/installing-command-line-mp3-player/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://arvinderkang.com/wp-content/uploads/2008/06/mpg-123-player.png" alt="Mpg 123 Player" /></p>

<p><a href="http://www.mpg123.de/" title="mpg123, Fast MP3 Player for Linux and UNIX systems">mpg123</a> is a real time MPEG 1.0/2.0/2.5 audio player for layers 1,2 and 3.</p>

<p>I was playing with Ruby scripts and needed a command line mp3 player which was not a resource hog.</p>

<p>Steps I took for my OS X (Should work on Linux/Unix box):</p>

<p>Download the latest version from <a href="http://www.mpg123.de/download.shtml" title="mpg123: download">the website</a>.</p>

<p>Untar the archive</p>

<pre><code>tar -xvf mpg123-1.4.3.tar
</code></pre>

<p>Compile and install the player</p>

<pre><code>./configure --prefix=/usr/local/mpg123
make
make install
</code></pre>

<p>Add the path to .bash&#95;profile</p>

<pre><code>echo 'export PATH=/usr/local/mpg123/bin:$PATH' &gt;&gt; ~/.bash_profile
</code></pre>

<p>Load the new path</p>

<pre><code>source ~/.bash_profile
</code></pre>

<p>Enjoy playing music from command-line!</p>

<pre><code> mpg123 ~/Music/Bagho_Bagh_Gippy_Grewal.mp3
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://arvinderkang.com/2008/06/28/installing-command-line-mp3-player/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->