Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2237
  • Last Modified:

Connecting PB to Windows Media Player OLE Control

I have a window which has an OLE Control which is the Windows Media Player Active X control. But when I type in 'player.controls.stop()' for example, it will not compile as it says the player object does not exist. How can I instantiate the com object properly so that I can connect to the server and call the wmp com functions.
0
Omnipower
Asked:
Omnipower
2 Solutions
 
gajender_99Commented:
Function Boolean mciGetErrorStringA(long dwError, ref string lpstrbuffer, int wlength)LIBRARY   "WINMM.DLL"
FUNCTION boolean sndPlaySoundA(string wavfile, uint flag) LIBRARY "WINMM.DLL"
FUNCTION uint waveOutGetNumDevs() LIBRARY "WINMM.DLL"
FUNCTION Long mciSendStringA(string lpstrCommand,  ref string lpstrRtnstring, long wRtnlength, long hCallBack) LIBRARY   "WINMM.DLL"

string s_errortext
string filename
filename = "party.mov"
mciSendStringA ("open "+Filename,s_errortext, 127,0)
mciSendStringA ("Window " +filename+" Handle "+string(handle(dw_3))+" wait",s_errortext,127, 0)
mciSendStringA ("Put "+filename+"Destination",s_errortext, 127, 0)
mciSendStringA ("Set "+filename+" time format frames", s_errortext,127, 0)
mciSendStringA ("Seek "+filename + " to 1",s_errortext,127,0)
mciSendStringA ("Play "+filename, s_errortext,127, 0)
0
 
berXpertCommented:
Hi Omnipower,

To access the properties of your player you need to call them from OBJECT property of your OLEControl.

So for:  player.controls.stop()
Use :    ole_1.object.controls.stop()

Here it sample code that:

1. activate OLEControl
2. Display WMP Version in a messagebox
3. Set a video file to be played
4. Play video
5. Display a Messagebox with the name of the file being played, when you close this messagebox video is Stoped

You need:

A window containing an OLEControl OLE_wmp : Object type Windows Media Player, Unchecked "Display as Icon"
and a CommandButton cb_1

//---------------------------
// Click event on cb_1
//---------------------------
String ls

ole_wmp.Activate(InPlace!)

ls = ole_wmp.object.versionInfo

MessageBox("Version", ls)

ole_wmp.object.URL = "C:\\videos\\BerXpert.wmv"
ole_wmp.object.controls.Play()

ls = ole_wmp.object.URL
MessageBox("URL", ls )

ole_wmp.object.controls.Stop()

//---------------------------
// ... End
//---------------------------


I hope it helps,

BerXpert
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now