We help IT Professionals succeed at work.

Making an mp3 server to broadcast over intercomm system

tommoran
tommoran asked
on
Medium Priority
312 Views
Last Modified: 2010-03-18
I have an older pc that I want to turn into a mp3 server (sorta).  What it will do is just be barebones Redhat and have a text-based mp3 player that can be remotely administered via ssh.  this way I can just setup a smb share to the server to drop mp3 files and the player can then pickup a playlist from a directory and loop through all the songs.

Any ideas?  I've seen a few mp3 players for linux but I'm a little uncertain how to get it to run with very little user interaction.

Thanks in advance,
Tom
Comment
Watch Question

Commented:
Let me see if I understand what you want. You have some speakers hooked up to this other computer and you want to be able to copy mp3's from a folder on one computer to this one. I think this shouldn't be to diffucult, I think the major problem is finding  a console based mp3 player for linux, thus administartion through SSH is possible. Well thankfully sourceforge.net has all the answers. I have posted a link to their site that searche for console mp3. One of these tools should probaly fit your needs. Just install the console player, and wirtie a simple bash script to generate a playlist from the smb directory, then send the playlist to the console program.

Author

Commented:
That's awesome.  Although I may need to repost for some help with that bash script you are suggesting.  I really like that idea though.  Thank you for the input.  I didn't see the link you posted but I am a bit familiar with sourceforge and so i'll try a search on the same terms.

Thanks

Author

Commented:
Found one called music on console.  Giving it a run for the money.  I'll post with my status.  I should be finished by the end of the day.
Commented:
Your bash script should be relatively simple, just mess with the mp3 console program, and their should be some option like "mp3console -generateplalist /usr/mp3 /home/me/plist.plt" then another command
like "mp3console -playlist /home/me/plist.plt". Do not take these literally, these are just examples of made up commands. Once you have all the commands down, you can create a bash script. A bash script is exactly like a batch file for DOS/Windows. Just put the commands you want to execute in a file and run it. However Linux has some funny rules, first the extension doesn't matter there is actually a flag you have to set with chmod to make the file executable. I think it's chmod 777, and also make sure to fully qualify your locations like "/usr/bin/mp3console -generateplaylist". Googling bash scripts will give you quite a few useful tutorials.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
XoF

Commented:
what's wrong with mpg123?

mpg123 /mp3-dir/*

or:

#!/bin/bash
while true
do
  if [ -f /mp3-dir/ctrl/play ]
  then
    while true
    do
      for song in /mp3-dir/ctrl/playlist.txt
      do
         [ -f /mp3-dir/ctrl/play ] || break
         mpg123 /mp3-dir/$song
      done
    done
    [ -f /mp3-dir/ctrl/loop ] || break
    [ -f /mp3-dir/ctrl/play ] || break
  fi
  sleep 5
done



this will allow you to place a list of filenames as playlist.txt in the ctrl-directory.
A few seconds after placing a file called "play" in ctrl-dir, the player will start playing the songs on the list. when the file "loop" exists in ctrl-dir, the playlist will be played in an endless loop, as long as the file exists. When the "play" file gets removed, the player will stop after the current song.

just some creative input....

HTH,
-XoF-

Author

Commented:
That's pretty cool also.  One thing that music on console is able to do is add songs to the playlist on the fly.  For example, I have a smb share to the directory where the music on console gets it's playlist.  All I have to do is drop mp3's into that directory and with no intervention at all they are added to the playlist.  I think that's pretty dang cool.
XoF
Commented:
oops, error:

replace
for song in /mp3-dir/ctrl/playlist.txt
with
for song in $(cat /mp3-dir/ctrl/playlist.txt)

Alternative (without playlist-file):

#!/bin/bash
while true
do
  if [ -f /mp3-dir/ctrl/play ]
  then
    while [ -f /mp3-dir/ctrl/play ]
    do
      for song in /mp3-dir/*
      do
         [ -f /mp3-dir/ctrl/play ] || break
         mpg123 $song
      done
    done
    [ -f /mp3-dir/ctrl/loop ] || break
  fi
  sleep 5
done


Now it simply plays all songs in /mp3-dir. Just drop songs there, they will be played automatically in the next loop....


cheers,
-XoF-

Commented:
Thats a great idea, but was under the impression the user wanted a simple GUI accesable through SSH, so they could control the music from another PC.

Author

Commented:
You are correct kamichie and thus the reason I chose a text-based mp3 player.  Then I started to think about being able to just drop files into a smb share and have them automatically added to the playlist.  I still am tweeking it to play correctly but it seems it will work really well.  XoF was giving a great idea for the bash script that I eluded to in my previous post.  I'm sorry if I was too confusing in my post, I tend to do that sometimes.  Opening my mind up to alternatives is what I love so much about EE.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.