[Haskell-cafe] using createProcess and waitForProcess, but mpg123 plays for only 6 seconds

rnons remotenonsense at gmail.com
Thu Nov 15 12:18:46 CET 2012


Hi guys,

I'm building an application that needs to wrap an external mp3 player, in  
this case mpg123.

Here is my code:

import System.IO
import System.Process
import Control.Concurrent

mpgLoop = do
     let sh = "mpg123 -R"
     (Just hin, Just hout, _, hdl) <- createProcess (shell sh){ std_in =  
CreatePipe, std_out=CreatePipe }
     --hPutStrLn hin "SILENCE"
     hPutStrLn hin "LOAD /home/rnons/Music/test.mp3"
     hFlush hin
     waitForProcess hdl
     return ()

main = do
     forkIO mpgLoop
     -- threadDelay 20000000
     getChar


I expected with "waitForProcess", this program will be able to run till  
the song ends. However, mpg123 plays for only 6 seconds.

Maybe I missed something?

rnons



More information about the Haskell-Cafe mailing list