From: Adam Shelly Date: 2006-01-13T06:50:11+09:00 Subject: Re: Newbie question on music/windows This sounded like an interesting challenge - here's a simple interface to the Windows Media Player: --- # SimpleWinMediaPlayer.rb # - Adam Shelly, January 2006 # require "win32ole" class SimpleWinMediaPlayer def initialize @mp = WIN32OLE.new("WMPlayer.ocx") p @mp @control = @mp.controls end def file= str @mp.URL= str @media = @mp.currentMedia @control.currentItem = @media end def file @mp.url end def play if @control.isAvailable "play" @control.play else @control.playItem @control.currentItem end end def pause @control.pause end def stop @control.stop end def rewind if @control.isAvailable "fastReverse" @control.fastReverse else seek_to 0 end end def fforward @control.fastForward end def current_pos @control.currentPositionString end def seek_to pos # takes argument as S[.ms] or "S[.ms]" or "[MM]:SS[:ms]" if pos =~ /(\d*):(\d+)(:(\d*))?/ pos = $1.to_f*60+$2.to_f+$4.to_f/1000.0 end @control.currentPosition = pos.to_f end def duration @media.duration end end ---- basic usage: player = SimpleWinMediaPlayer.new player.file = "c:/whatever.mp3" player.play Hope this helps -Adam On 1/12/06, Jb Piacentino wrote: > Yes I got this one, but this only deals with getting infos on the file - > does not help me with playing it ! > > --