I received a customer question:

 

I have searched the net and asked as many people as I could and could not get an answer, so I am bothering you.
Do you know of a way to get VFP to play mp3 format tunes? There must be a way to use a media player driver or ActiveX to make this happen. Any ideas?

 

For a simple way to start an mp3 file, try this in the command window:

!start d:\piano.mp3

 

A more elegant solution: try out the Fox Media player that comes with VFP9:  Start the Task Pane: choose Solution Samples->New in VFP 9->Fox Media Player

 

 

Or you can run this code from that sample. (I tried it in VFP8 and it works: I had to remove some VFP 9 specific features, such as anchoring).

 

playit("D:\piano.mp3")

*playit("D:\Calvinh\My Music\Claude Bolling\2003. Pariswing\02. La Mer.wma")

PROCEDURE playit(tcURL, tnDrive)

 

LOCAL loError, loCD

IF VARTYPE(tcURL)#"C" OR EMPTY(tcURL)

      * Sample URL

      tcURL = "http://radio.livephish.com:8000"

ENDIF

 

      IF TYPE("_SCREEN.oWMP")#"O"

            _SCREEN.ADDOBJECT("oWMP","WMPContainer")

            WITH _SCREEN.oWMP

                  .HEIGHT = _SCREEN.HEIGHT

                  .WIDTH = _SCREEN.WIDTH

                  .VISIBLE=.T.

            ENDWITH

      ENDIF

      IF UPPER(tcURL)=="CD"

            IF tnDrive = -1

                  RETURN

            ENDIF

            loCD = _SCREEN.oWMP.oleWMP.cdromCollection.ITEM(tnDrive)

            _SCREEN.oWMP.oleWMP.currentPlaylist = loCD.Playlist

      ELSE

            _SCREEN.oWMP.oleWMP.url = tcURL

      ENDIF

 

 

 

 

 

 

*---------- CLASSES ----------------------------------

DEFINE CLASS WMPContainer AS CONTAINER

      oWMPToolBar = NULL

 

      ADD OBJECT oleWMP AS OLECONTROL WITH ;

            OLECLASS = 'WMPlayer.OCX'

 

      ADD OBJECT tmrWMP1 AS tmrWMP

 

      PROCEDURE INIT

            THIS.oleWMP.WIDTH = THIS.WIDTH

            THIS.oleWMP.HEIGHT = THIS.HEIGHT

            THIS.oWMPToolBar = ;

                  NEWOBJECT('WMPToolBar', SYS(16), NULL, THIS)

            THIS.oWMPToolBar.VISIBLE = .T.

      ENDPROC

 

      PROCEDURE RELEASE

            _SCREEN.LOCKSCREEN = .T.

            THIS.REMOVEOBJECT('oleWMP')

            RELEASE THIS

            _SCREEN.LOCKSCREEN = .F.

      ENDPROC

 

      PROCEDURE oleWMP.DoubleClick(p1,p2,p3,p4)

            THIS.VISIBLE = .F.

            THIS.PARENT.VISIBLE = .F.

            THIS.PARENT.oWMPToolBar = NULL

            THIS.PARENT.tmrWMP1.ENABLED = .T.

      ENDPROC

ENDDEFINE

 

 

 

 

*--------------------------------------------

DEFINE CLASS WMPToolBar AS TOOLBAR

      SHOWTIPS = .T.

      CAPTION = 'Fox Media Player'

      WMPContainer = NULL

 

      ADD OBJECT CmdClose AS COMMANDBUTTON WITH ;

            TOOLTIPTEXT = 'Close Fox Media Player', ;

            PICTURE = HOME() + 'tools\test\close.bmp', ;

            SPECIALEFFECT = 2, ;

            HEIGHT = 22, WIDTH = 140

 

      PROC INIT(WMPContainer AS OBJECT)

            THIS.WMPContainer = WMPContainer

      ENDPROC

 

      PROCEDURE CmdClose.CLICK

            THIS.PARENT.WMPContainer.oleWMP.DoubleClick()

      ENDPROC

ENDDEFINE

 

 

 

 

*--------------------------------------------

DEFINE CLASS tmrWMP AS TIMER

      INTERVAL = 500

      ENABLED = .F.

      PROCEDURE TIMER

            THIS.PARENT.RELEASE()

      ENDPROC

ENDDEFINE

 

 

 

46181