LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

EndOfStream Callbackfunction for WindowsMediaPlayer

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
0 Kudos
Message 1 of 2
(3,401 Views)

Hi Paco, not sure I understand the question, but I've got a good idea what your problem is.

 

You can see from the Windows Media Player SDK documentation (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/playerobject.asp) that the EndOfStream event is "Reserved for Future Use".  Which, in Microsoft speak, means it's broken :-).  I played with it for a while and was unable to get it to fire.  I think you'll have a lot more luck using the PlayStateChange method.  It requires slightly more work, since you have to check whether the play state is wmppsStopped, but it works.

 

Regards,

Ryan K.

Message Edited by ryank on 09-02-2005 09:37 AM

0 Kudos
Message 2 of 2
(3,383 Views)