Topic: Any way to play pls streams via command line?

I know there are ways to stream from an mp3 server via command line thanks to the Chumby Tricks page but is there any way to stream from a pls based site?

For example http://groove.monkeyradio.org

This works via the My Streams part under Music in the OFW but I'd like to know other ways for when the servers go dark.

Re: Any way to play pls streams via command line?

Answered my own question

On a pc if you go to http://grove.monkeyradio.org it'll prompt you to save "listen.pls"

Open in in a text editor and it shows

[playlist]
NumberOfEntries=1
File1=http://76.73.3.245:6969/

SSH into your Chumby and enter and it works!
btplay http://76.73.3.245:6969/

Re: Any way to play pls streams via command line?

So how do you listen to an m3u stream that's your own "My Streams" playlist, from the command line?  Still can't work this out.

For example, say I have the file "/mnt/usb/Music/AllSongs.m3u" which I have made into a stream called "All Songs" with stream url="file:////mnt/usb/Music/AllSongs.m3u" ....you'd think I could then do:
btplay file:////mnt/usb/Music/AllSongs.m3u
perhaps?

But this doesn't work.  What am I missing?

Re: Any way to play pls streams via command line?

M3U files are not audio files - they're a playlist of URLs (much like  PLS file) to the actual audio.

btplay only understands paths/URLs to actual audio files.

The "My Streams" section of the Control Panel understands what PLS and M3U files are, fetches them, and extracts the actual URLs and passes them to btplay.

Re: Any way to play pls streams via command line?

Right.  So how do I start a playlist, or a stream, or anything more than just one mp3, from the command line?  CAN I use MyStreams from the command line somehow?

Re: Any way to play pls streams via command line?

I think Duane is saying that that won't work, if you're sending an actual path (not a URL) to the device then it requires an actual audio file.

That being said what if you did something like btplay http://127.0.0.1/mnt/usb/Music/Allsongs.m3u
The 127.0.0.1 is your device. No idea if this will work or not but its worth a try. I'll see if I can create an m3u playlist and try it out myself.

Re: Any way to play pls streams via command line?

All I want is the ability to start, and control, a  bunch of songs playing from the command line.  Some days I'm in too much pain to get up and cross the room to the chumby--and particularly to stand there while the chumby gui s.l.o.w.l.y goes through all the screens it takes to start music playing and then back out to the clock channel again.  But my days are always, always better with good music playing.

I've got little scripts to control the music once it's playing.  I've got little scripts to search for and play a single song based on its name.  I've got little scripts to re-shuffle my m3us so that when it plays a stream as an alarm, it plays something different each time. 

I just can't work out how to *start* it playing when I'm over here, it's over there, and it's one of those Really Bad Days. 

Well, not and keep my clock display, anyway.  I can make the alarm go off any time by altering the alarms file and reloading the alarms (another little script), but then I lose my time/date/temperature station.

I can do little scripts.  I can't do much more than that.  I just want to be able to start up the music from over here.  What am I missing?  What don't I know?

I would *love* to be able to play last.fm or pandora or some other personalized music station via the ssh command line.  I would be delighted to just be able to start up a mystream consisting of an m3u file, or something else that just exists on the chumby's own drive/usb drive.

Zurk said http://sourceforge.net/projects/zurk/fo … ic/5291647 here that it should be possible to run last.fm on a chumby, but I don't have any idea how to use those files.  I think they assume more familiarity with python than I have, or something.

I've been trying to figure out how to use squeezebox and rhythmbox to send last.fm to the chumby, but can't work that out, either.  I *can* send my own mp3's via the clunky browser interface...but if they're also on the chumby, surely there is a more elegant solution?  Why pipe my own mp3's across the wifi from my desktop when they're already THERE?

...I am frustrated.  I keep running headfirst into a wall, and I think it's *something* that I just don't know well enough.  I can only manage little bash scripts: enough to know that there IS more possibility out there, but I just don't have the knowledge to make it work.  I don't even have the knowhow to look it up and understand it.

8 (edited by jphphotography 2012-05-27 14:54:21)

Re: Any way to play pls streams via command line?

Ok so this doesn't work "as is" but I'm sure I'm on the right track. By default the device is running a webserver, httpd, but its only serving pages from /www/cgi-bin.

I stopped httpd and restarted it with httpd -h /mnt/storage/music/ which now should serve files from the music folder I created under /mnt/storage/music

I wrote an m3u playlist file (on the infocast to it has the proper carriage returns etc) and tested it under windows to confirm it works.

If I try btplay http://127.0.0.1/mymp3file.mp3 it will play the file but if I try the playlist file it does not work.

[Update]
After rereading Duane's post and reading more in the BTPLAY documentation I realize that it simply isn't possible. I misread Duane's comment about MyStreams recognizing a playlist when its presented as a URL and not a path, this is why I configured httpd to give it a URL. My mistake was that MyStreams is not BTPLAY so as Duane states it can only play actual music files or streams from an actual mp3 server.

So in short I don't think this is possible the way you want to do it, MyStreams is interpreting the playlist itself and the serving BTPLAY with the commands it wants to hear.

Oh well this gave me a chance to play around and learn somemore smile

Re: Any way to play pls streams via command line?

The approach to do this is to create a small script to download the M3U files, extract the URLs for the actual streams, then send them one-by-one to btplay. The script would have to monitor the status of btplay to see if it's done playing one file before playing the next one.

Re: Any way to play pls streams via command line?

Oh!  Oh, that script I think I might be able to do, indeed so.  I think I can do that.  I even think my "search for a file by name and play it" script might even have most of the components.

How do you monitor btplay?  What do you use?

Thank you!  Thank you!

Re: Any way to play pls streams via command line?

btplay writes out status files to /var/run that tell what's going on

You might do a search on the wiki for btplay - you may find some helpful into there.

This page, for instance, lists some stuff you can do through the pipe interface, though I don't know if it's all still supported.  There was some support for playlists at some point, but not using PLS and M3U directly.

Re: Any way to play pls streams via command line?

Oh, I've read the wiki pages on btplay and audio; like I said, there are some things that I just don't KNOW, don't know how to use. 

I should mention that I'm a physics geek from the 90's; we learned FORTRAN by necessity, and bash scripting to make things more efficient, but all in a scattered and self-taught way.  I am not a computer geek, though I try to fake it ;) when I want to get something done.  Most of it's beyond me, and so I need to either be pointed in the right direction, or soemtimes even walked through it, before I can make it work.  I did try to use the wiki info on playlists and couldn't get it to work, but I don't know if that was me or the chumby.)

But usually, once you show me, I'll manage to hang onto it and make use of it.  For example, there's my song-shuffle cron jobs and "approximate random play" mp3 stream alarms, which I posted about here.  If I can get this working, I'll be happy to share it too, probably another update in the same thread, since it's still on the first page of this forum anyway.  I've wanted this since we got our first chumby several years ago; I can't be the only one :)

And I am eternally grateful for being  pointed in the right direction, too >grin<

Okay, how does one monitor a file?  I found the files in /var/run and I can see  how the contents of "/var/run/btplay.state" change when it is playing.  Is this a job for cron?  That seems kind of inefficient.

Re: Any way to play pls streams via command line?

It's nice to have buddies who are perl gods wink  We're working on ironing out the bugs but we do have a solution mostly done at this point.  The script will take an .m3u file as an argument and play the songs in order until stopped.  With the other scripts I posted in the "random alarms" thread it's possible to keep playing random songs from the command line until your ears bleed.  I can play my music from across the room, control it (skip to next song, stop, etc), all while continuing to display my default chumby channel.

Script will be posted once it's complete, with permission of the author.

Re: Any way to play pls streams via command line?

galadriel wrote:

It's nice to have buddies who are perl gods wink

I feel the exact opposite way... tongue

Linux Guy - Occasional Chumby Hacker

Re: Any way to play pls streams via command line?

Materdaddy wrote:
galadriel wrote:

It's nice to have buddies who are perl gods ;)

I feel the exact opposite way... :P

Aw!  Heh.  I just asked them how one monitors a file and described its behavior, looking for some tips on the bash script.  Ten minutes later, one says, "Here, try this." 

Well, anyway, I am sending him an Amazon special Infocast, by way of thanks, and because he keeps asking if there's a Chumby environment emulator so he could play with the bugs directly.  So I'm not *just* a leech on my perlgod friends :P

Re: Any way to play pls streams via command line?

I'm just giving perl gurus a hard time.  I prefer bash/python to perl because I'm not very versed and perl can be really hard to read.  I'm glad somebody was able to help you get further with your task!  Hopefully it works great so we can all take advantage of the work done by your friend.

Linux Guy - Occasional Chumby Hacker

Re: Any way to play pls streams via command line?

LOL I like to give perl users a hard time too -- I personally find it quite hard to read and confusing to understand.  I speak fluent PHP, passable bash, a smattering of Python, and a handful of other languages that are less relevant to Chumby.  Of all the languages I've learned, perl has not been one of them, and not for lack of trying tongue

Re: Any way to play pls streams via command line?

I'll update again if we get things more ironed out; for the moment, the problems that come up seem to be due to buggy btplay, not to the script.  Here it is:
http://lady-of-lothlorien.com/chumby/bin/play_list

To operate, feed it:

play_list [name of your file containing list of songs with full path] &

Other commands,

play_list --next 
play_list --stop

should be pretty self-explanatory, I think.

Don't forget you can use http://lady-of-lothlorien.com/chumby/bin/random_reorder to shuffle your songlist between playings.

If you need a reminder, you can get the scripts and make songlists and so on with the various below commands--which assumes you have your music files on a USB drive at /mnt.usb/Music:

 
mkdir /mnt/usb/bin/
cd /mnt/usb/bin
wget http://lady-of-lothlorien.com/chumby/bin/play_list
wget http://lady-of-lothlorien.com/chumby/bin/random_reorder
chmod u+x *

nano /psp/.profile [and add :/mnt/usb/bin/ to the end of your PATH]

cd
find /mnt/usb/Music/ -type f > /mnt/usb/Music/AllSongs.m3u [you only need to do this once]
random_reorder /mnt/usb/Music/AllSongs.m3u [you can do this any time you play your music]

play_list /mnt/usb/Music/AllSongs.m3u &

19 (edited by jphphotography 2012-06-07 15:14:00)

Re: Any way to play pls streams via command line?

Just out of curiosity would this have been another, possibly easier way to do this via command line?

echo "<event type="UserPlayer" value="play" comment="http://path.to.stream"/>"
chumbyflashplayer.x -F1

Where you would replace http://path.to.stream with file:////path.to.stream if it was a locally stored m3u

Since it would be using the controlpanel would that be handled by the same code that runs mystreams and therefore allow it to process the m3u appropriately?

I'd try it right now but my poor little infocast has been working overtime trying to compile and configure dependencies for MPD (its going to take FOREVER smile

Re: Any way to play pls streams via command line?

Would have been nice, easier, but didn't work.  Even if the m3u was already defined as a stream in /psp/url_streams and could be played from the control panel/music screen.  Copy/pasting the stream from /psp/url_streams (in case of typos) didn't work.  If you recall, trying to use streams from the command line somehow was what I was originally asking for.

http://wiki.chumby.com/index.php/Controlling_BTplay also claims that btplay has some playlist capability, but I couldn't get anything on there to work either.

But hey, that play_list script is working beautifully, aside from where btplay itself is buggy (and always has been, even when playing a single mp3 from the command line one at a time).

Your poor little infocast!  I guess setting up another, more powerful computer to do compiling didn't work out, huh?  Well, someday it'll be done smile

21 (edited by jphphotography 2012-06-07 14:04:45)

Re: Any way to play pls streams via command line?

@Galadriel, yes I know that playing streams/playlists from command line is what your original post was about and that should be exactly what this will do. We did come to the conclusion that btplay won't do it directly however this isn't directly talking to btplay, this should be passing the info to the control panel which will then (hopefully) use its "my streams" code to play the stream or playlist. I know your script method is working and thats awesome, I just figured this might even be an easier way and less dependent on scripting etc which may scare others off smile

Anyway, I accidentally left out an important part in the commands I posted, the echo part is supposed to be writing that info to a file in /tmp/flashplayer.event and it also looks like my code won't call the other script properly.

Try this

echo '<event type="UserPlayer" value="play" comment="http://path.to.stream"/>' > /tmp/flashplayer.event
/usr/bin/chumbyflashplayer.x -F1

I also noticed on the chumby tricks page a different example is using single quotes outside of the echo command so that might have also been messing things up.

Try it and let me know!

Re: Any way to play pls streams via command line?

I'm sorry, I suppose it wasn't clear: I'd tried all of that *before*.  Yes, it would be lovely if it'd work that way, but no, it doesn't.  I also tried writing it into scripts that would do it for me with the filename as an argument in case that would convince it to see it as a stream, and all different varieties of types of quotes and even things like `cat [the m3u file]` (etc etc).

That's not to say I get errors or that it refuses to even try.  But if I enter, for example:

echo '<event type="UserPlayer" value="play" comment="file:////mnt/usb/Music/Garbage.m3u"/>' > /tmp/flashplayer.event
/usr/bin/chumbyflashplayer.x -F1

Then "more /var/run/btplay.properties" will tell me:

Tags/Title=Garbage.m3u

Which is to say, it tried to play a text file. 

And "more /var/run/btplay/state" returns a 1, which is "not playing anything."  It tried to play the m3u file, it couldn't, and it gave up.


I do suspect if there were some way to wrench this particular bit (sending a local playlist stream to the control panel) into a workable solution... that Duane would have mentioned it earlier in the thread when he replied.  Or that chumby tech support might have done so when I emailed them years ago asking for some way to play a playlist from the command line.

Re: Any way to play pls streams via command line?

UserPlayer only accepts streams.  m3u files are not streams.

I think it's also the case that it doesn't understand the "file://" protocol handler - just use a local file system path.  UserPlayer simply passes these to btplay.

I'll take a look to see much effort it would be to "smarten" UserPlayer to accept PLS and M3U playlists.  The bulk of the code is in there for My Streams, so it might not be too much work.

I can also look into having UserPlayer give more feedback about what it's doing, for instance writing out files to /tmp that give the status to scripts that are trying to drive it.