XMMS-0.1: example/tut3.hs
import System
import Network.XMMS.Playback
import Network.XMMS.Client
import Network.XMMS.Medialib
import Data.Map (Map)
import Data.Map as Map
import Prelude hiding (init)
main = do
connection <- init "tutorial3"
xmmsPath <- catch (getEnv "XMMS_PATH")
(\e -> return "")
connectRes <- connect connection xmmsPath
if connectRes == 0 then do
errorMsg <- getLastError connection
putStrLn $ "Connection failed: " ++ errorMsg
else do
result <- currentID connection
resultWait result
returnValue <- resultGetValue result
case returnValue of
XMMSError msg -> putStrLn $ "playback start returned error: " ++ msg
XMMSInt id -> do
putStrLn $ "playing track with ID:" ++ show id
result <- medialibGetInfo connection id
resultWait result
returnValue <- resultGetValue result
case returnValue of
XMMSDict dict -> mapM_ (\(key, value) -> putStrLn (key ++ " : " ++ show value)) (assocs $ propdictToDict dict)
_ -> error "not a dictionary"
return ()
_ -> return ()