Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Mp3 PLayer. Part Two!

by panix (Monk)
on Sep 20, 2002 at 01:23 UTC ( #199358=note: print w/replies, xml ) Need Help??


in reply to Mp3 PLayer. Part Two!

Question one: Is there anyway i could easily start/stop a process from perl?

Isn't the problem that you don't know the pid to kill?

Just a suggestion - maybe it would be easier to have perl streaming the current mp3 to a fifo, and have mpg123 play that? See the .signature example in perlipc for a working example.

Question two: Is there anyway to convince perl to read/write mp3 files without dying

You were already on the right track :)

Here's an example of what I meant in 199077:

adam@2cb:~$ perl -e 'open F, "nofx - falling in love.mp3"; binmode F; +open G, ">bleh"; binmode G; while(<F>) { print G; } ' adam@2cb:~$ ls -la nofx\ -\ falling\ in\ love.mp3 bleh -rw-r--r-- 1 adam users 5011330 Sep 20 13:00 bleh -rw-r--r-- 1 adam users 5011330 Jan 24 2002 nofx\ -\ falli +ng\ in\ love.mp3 adam@2cb:~$ cksum nofx\ -\ falling\ in\ love.mp3 bleh 2095826934 5011330 nofx - falling in love.mp3 2095826934 5011330 bleh

The original/new files end up exactly the same - perl is handling the binary data just fine.

update: added binmode G;. example was only working without it because i'm a linux weenie?

Replies are listed 'Best First'.
Re: Re: Mp3 PLayer. Part Two!
by grantm (Parson) on Sep 20, 2002 at 01:32 UTC

    Don't you need a binmode G; in there?

Re: Re: Mp3 PLayer. Part Two!
by BUU (Prior) on Sep 20, 2002 at 02:01 UTC
    >>"Isn't the problem that you don't know the pid to kill?"
    Er, when i call kill on the pid for mpg123, nothing happens, it just continues on merrily. (maybe b/c its cygwin or something)

    As to the printing thing, you're right, i just didnt have enough binmodes in there. I'll try again using binmode.

    And quick update to my root node, where it says "one that would 'waste' all the resources", should read "would not waste..", as that actually makes sense.
      Sounds like you are using Win9x instead of a flavor of NT... Kill does not work on 9x flavors of Windows.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://199358]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2019-12-05 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (151 votes). Check out past polls.

    Notices?