Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem on displaying windows media player

Status
Not open for further replies.

gutay008

Programmer
Nov 9, 2015
34
PH
I have here a code for playing videos with wmp in a form.

thisform.olecontrol1.url = "C:\Users\Desktop\1.avi"
thisform.olecontrol1.height = 500
thisform.olecontrol1.width = 300
thisform.olecontrol1.uiMode = "none"
thisform.olecontrol1.STRETCHTOFIT = .f.
thisform.olecontrol1.enableContextMenu = .f.
thisform.olecontrol1.settings.autoStart = .T.
thisform.olecontrol1.settings.setMode("Loop",.T.)
thisform.olecontrol1.anchor=15

but the problem is whenever i run the form, the wmp gets larger, then when i tried to resize the form, thats the only time the wmp resize itself with the given height and width.
em i missing something here? i want to play the video with the given height and with.

thanks in advance
 
Then you don't want to anchor the olecontol. Last line, remove that.

Bye, Olaf.
 
Tried to remove the anchor but the same happens. Upon running the form, it actually gets the set height and width but after few seconds the wmp changes its size.
 
Then I may have a misunderstanding. What do you mean with the given height and width? Given by the form or given by the video?

Bye, Olaf.
 
upon checking the video details: the frame width was 1280 and height of 720 . i think it uses the size of the actual frame of the video.
 
And you want it to fit your form size? Then set STRETCHTOFIT = .T. of course. Why do you set this to .f., if you want the video to stretch and fit in your form?

Bye, Olaf.
 
nope, i dont want to fit it on the form. i want to play the video with the height and width i set.
 
Well, that still is stretchtofit. You may not want the control to resize with your form, then, so keep anchoring off, but set the control to the size you want and stretchtofit=.t. and the video stretches to the size you set.

Bye, Olaf.
 
I experimented a bit and even with stretchtofit it seems you have to wait for the video to play before you can enforce your own dimensions.
There are some events, eg the StatusChange occurs, when the video starts. It's still a bit too early to enforce your own dimensions, the automatic fit to original size happens shortly afterwards.

Maybe someone else has a solution, at least stretchtofit =.t. and anchor=15 give you control over the video size when it's playing.

Bye, Olaf.





 
Thanks sir olaf for the time with me. After many tries, i did was to hide the olecontrol upon running the form then after few seconds i call the width and height i want and unhide the olecontrol. This trick fix my problem on the width and height of the olecontrol. You were right sir olaf for me to wait the video to play before i can enforce the dimension i want.

Thanks
 
The best way to handle this is to embed WMP into HTML and then render using the web browser control. This allows you to have a lot of control over WMP. Here is a basic sample:

TEXT TO lcHTML TEXTMERGE NOSHOW
<html>
<body scroll="no" style="border: none" topmargin="0" leftmargin="0" oncontextmenu="return false;">
<object id="mediaPlayer" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" height="<<This.HTMLHeight>>" width="<<This.HTMLWidth>>">
<param name="autoStart" value="false" />
<param name="URL" value="<<ALLTRIM(tcHTMLURL)>>" />
<param name="enableContextMenu" value="false" />
<param name="stretchToFit" value="true" />
</object>
</body>
</html>
ENDTEXT

Where tcHTMLURL is the path to the media.
Then This.oleWebEmbed.Navigate(lcHTML)

You can also do stuff like this for play, stop, pause if there is a need outside user interaction with the WMP control:

loWMP = This.oleWebEmbed.Document.getElementById("mediaPlayer")

IF VARTYPE(loWMP) = "O"
IF loWMP.controls.isAvailable("play")
loWMP.controls.play()
ENDIF
ENDIF

Keep in mind that there is more to implement to make an effective WMP control class. Just providing the basics here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top