LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to play MP3-Files in LabWindow/CVI?

Hello,

i have written a programm in LabWindow/CVI which can play WAV-Files, but I also want to play MP3-Files. Is it possible to play MP3 with LabWindow/CVI or do I have to include a c++ written dll which can play MP3?

Kind regards
Paco
0 Kudos
Message 1 of 9
(5,184 Views)
Paco,

If you want to play .mp3 files, you could include the Windows Media Player ActiveX control in your application.

If you want to limit the types of files that are played, you could set the Windows Media Player ActiveX control to screen mode only (I would give you the function calls for these but they differ depending on what version of Windows Media Player you have on the machine) and create your own load button that has a selection box restricted to .mp3 extensions.

If you aren't familiar with ActiveX controls, run a search for 'ActiveX Controls' in the LabWindows/CVI help. There is some helpful information there.
0 Kudos
Message 2 of 9
(5,166 Views)
Here's a sample active-x project that uses Windows Media Player to play an MP3 file (or any other file Media Player supports). The user interface isn't much, but it will play the file hardcoded (search for MediaPlayer_IMediaPlayer2SetFileName in player.c). Right now it's like an audio version of a "Hello world" program.
To add to this sample, you could add browsing functions, use list boxes to create playlists, etc.
I'm sorry I can't find the original link I got this from, but it was somewhere on NI's site.
0 Kudos
Message 3 of 9
(5,158 Views)
OK, here's the sample.
0 Kudos
Message 4 of 9
(5,154 Views)
Thank you very much, I got it now. I had a problem because I'm using an older version of LabWindow/CVI.

But now I have got another problem. Wenn I start playing mp3-files, the program opens the normal Windows MediaPlayer in a separate Window. Is it possible to hide the Windows MediaPlayer?

Greets Paco

Message Edited by Paco on 04-21-2005 03:51 AM

0 Kudos
Message 5 of 9
(5,119 Views)
Paco,

Yes, it is possible to embed the ActiveX control into your application. In CVI 7.0, right click on the panel in your .uir file where you wish to have the ActiveX control located (as you would do when you are trying to insert any other type of control). From the control selection menu, choose ActiveX. A screen will pop up with a list of activeX controls that you can embed into your project. Select 'Windows Media Player' (should be one of the last choices as they are in alphabetical order).

In your code, when you are ready to get the object handle for the Windows Media Player ActiveX control use the GetActiveXCtrlFromObjHandle function.
0 Kudos
Message 6 of 9
(5,097 Views)
Hi

I still have a problem with including ActivX for playing mp3 in LabWindow/CVI version 6.0.

1. I have included the ActiveX control panel "Windows Media Player"
1.1 Afterwards I have "generate ActiveX Control Driver", so that I can use "wmp.fp"

2. In a next step I have used "GetActiveXCtrlObjHandle ()" to get the control ID of the AxtiveX panel that is associated with the CAObjHandle

3. Then I used "wmp.fp" from class "IWMPControls" the function "Open WindowsMediaPlayerIWMPControls" to open a mp3-file
3.3 Finally I included the function Play to play the mp3-file that is selected

All this doesn't work. So I have tryed several functions, but nothing worked. Is this the right includig ActiveX?

Thanks Paco
0 Kudos
Message 7 of 9
(5,049 Views)
Paco,

Try using the function WMPLib_IWMPPlayerSetURL to load the MP3. You will also need to use the function WMPLib_IWMPPlayerGetcontrols to get a valid handle to use with the WMPLib_IWMPControlsplay function. Your code should look something like this...

/*Get the object handle for the media player*/
GetObjHandleFromActiveXCtrl (myPanel, PANEL_MEDIAPLAYER, &mediaPlayerID);

/*Load the MP3 into the media player*/
WMPLib_IWMPPlayerSetURL (mediaPlayerID, NULL, "C:\\MySong.mp3");

/*Get the handle for the media player controls*/
WMPLib_IWMPPlayerGetcontrols (mediaPlayerID, NULL, &mediaPlayerControls);

/*Play the Mp3 file that was just loaded*/
WMPLib_IWMPControlsplay (mediaPlayerControls, NULL);
0 Kudos
Message 8 of 9
(5,039 Views)
It does work. Thank you very very much, you helped me alot.

Paco
0 Kudos
Message 9 of 9
(5,031 Views)