Hallo, i'm using WindowsMediaPlayer by ActiveX to play mp3-Files. To handle the player i have made my own buttons for example a Stopbutton und a Togglebutton Play/Pause.
When the player starts playing a file the Togglebutton ist set from play to pause. Now i want to set this button from pause to play at the End of Stream. Here is the code i'm using therefore. I also want to realise a Togglebutton as a Repeatbutton. When button is set WMP plays the file all the time, when button isn't set WMP stops.
#include "wmp.h"
int WMP_Control; //global variable
static WMPLibObj_IWMPMedia WMP_ID; //global variable
//Initialisation at the start of program
GetObjHandleFromActiveXCtrl (mainpanel, MAINPANEL_WMP, &WMP_ID);
WMPLib_IWMPPlayerGetcontrols (WMP_ID, NULL, &WMP_Control);
WMPLib_IWMPPlayerSetURL (WMP_ID, NULL, Path);
//PlayPauseButton callback
int CVICALLBACK PlayPauseCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int PlayPause;
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal(mainpanel, MAINPANEL_PlayPause,&PlayPause);
if(PlayPause == 0)
WMPLib_IWMPControlsplay (WMP_ID, NULL);
WMPLib__WMPOCXEventsRegOnEndOfStream(WMP_ID, EndOfStream, NULL, 1, NULL);
if(PlayPause == 1)
WMPLib_IWMPControlspause (WMP_ID, NULL);
break;
}
return 0;
}
//Function called at the End of Stream
HRESULT CVICALLBACK EndOfStream (CAObjHandle caServerObjHandle, void *caCallbackData, long result)
{
SetCtrlVal(mainpanel, MAINPANEL_PlayPause, 0);
return 0;
}
I'm using LabWindow/CVI 6.0. I hope somebody cann help me to realise this. Thanks
Paco