petems / mplayer-ruby

A Ruby Wrapper for MPlayer
http://mplayer-ruby.rubyforge.org/mplayer-ruby/index.html
MIT License
3 stars 4 forks source link

Waiting for mplayer #12

Open mainrs opened 7 years ago

mainrs commented 7 years ago

Is there some way to wait for the slave process to finish before exiting the script? The script starts the slave, plays the song and quits immediately.

dfyx commented 7 years ago

The Slave class exposes its process id, so you should be able to do something like the following:

player = MPlayer::Slave.new 'somefile.ogg'
# Do whatever
Process::waitpid2 player.pid

I agree that this might be useful for some users so it might get added as Slave#wait at some point. I don't actively use this gem anymore (basically because I replaced the project I needed it for with mpd) and I don't know about @petems but if you send a pull request I'll merge it.

mainrs commented 7 years ago

Can mpd be used through home-brew on a desktop PC? I would like to use it for http streams from soundcloud. Is this possible?

Ok, gonna make a pull request later on for it :)

dfyx commented 7 years ago

mpd offers binaries for Linux and Windows and there are clients for just about any platform. There's also another mpd-compatible server implementation but I can't remember the name right now.

My current setup is mpd running on a Banana Pi (think Raspberry Pi with slightly better hardware), Cantata as a client on Windows and macOS and mPad as a client on my iPad.

petems commented 7 years ago

Yep, it's on brew: http://brewformulas.org/Mpd

@SirWindfield Feel free to PR, I was using this gem actively for a project I was working on but have since moved to other stuff.

BTW, if you want to do http streams from Soundcloud, I recomend: https://github.com/grobie/soundcloud2000 👍

mainrs commented 7 years ago

BTW, if you want to do http streams from Soundcloud, I recomend: https://github.com/grobie/soundcloud2000 👍

I already found that one. I want to do something similar with another goal. Playing random songs by genres or artist and if I like them, I can simply type add <playlist> and it gets added to a playlist so I can later on download or buy them. The program does break against the ToS though, it downloads the files into a directory while running, meaning that you would get copies of songs that normally cost. I don't really "care" about that but I would like to have the "add" feature so ye, I decided to write my own.

dfyx commented 7 years ago

Yeah, in that case, mpd + ruby-mpd might be just the right combination for you.

mainrs commented 7 years ago

Mind getting me started a bit? The library internally uses the libmpd library. Basically, a server is running in the background that handles music playing and things like that. I couldn't find a method to just simply stream a file from the web. Do I just use the normal add method?

dfyx commented 7 years ago

mpd is basically a backend for media playback that you can control through tons of different clients. I haven't worked with ruby-mpd in a while but yes, you should be able to pass a url to add the same way you would pass a local path. You can even save them to playlists like normal songs.