Discussion:
VB6 and Video Part 2
(too old to reply)
Lorin
2007-09-21 18:32:04 UTC
Permalink
Thanks for all the help so far with mciSendString.
mlRet = mciSendString("open " & sAVIFile & " Type MPEGVideo alias AVI
wait", 0&, 0&, 0&)
Works like a champ ... but
The last and final question is -
Now that I can place the video in a PictureBox, how do I set the size of the
video?
If I do not use the PictureBox and use the native screen, I can drag the
corner and get any size vieo screen I want; I just do not want the Caption
Bar and I want the flexibility of the PictureBox (drag, menu etc).
I have looked at the docs and on newsgroups but cannot find how to tell the
mci to set the video size.
I see a reference to 'stretch' but cannot find details and am not sure if
that is what I want anyway.
Is it possible to set the video size?
Mike Williams
2007-09-21 19:27:35 UTC
Permalink
Post by Lorin
Thanks for all the help so far with mciSendString.
. . . . . Works like a champ ... but The last and final
question is . . . . . -
I don't believe that, Lorin! Surely you can't mean that? "The last and final
question"? Sheesh! The last and final question I ask will be the question I
ask immediately before I die! I'm not sure what it will be yet, but it won't
be more than about 15 years away I reckon, and I'm working on it ;-)
Post by Lorin
Now that I can place the video in a PictureBox,
how do I set the size of the video? [big snip] If
I do not use the PictureBox and use the native#
screen, I can drag the corner and get any size video
screen I want. I want the flexibility of the PictureBox
(drag, menu etc). I have looked at the docs and on
newsgroups but cannot find how to tell the mci to set
the video size.
I'm really not very heavily "into" this video stuff, Lorin, but whenever I
want to play a video in VB6 (which admittedly, as an "oldie", is not very
often because we usually "listen to the wireless"!) I use the Active Movie
Type Library, which lives in Quartz.dll and which is installed by default on
all versions of Windows (certainly on all versions from Win98 to Vista) and
which therefore does not require you to distribute anything with your VB6
exe file.

Here is an example which plays a mpg video and which sizes the video to the
current size of the Picture Box. Paste the code into a VB Form containing a
Picture Box and a Command Button. Obviously, you will need to change the
hard coded .mpg path to an .mpg file that exists on your own system.

You will also need to use the VB IDE Project / References menu and scroll
down the list and place a tick against Activemovie control type library. If
you cannot find it in the list then click the "Browse" button and browse to
System32/Quartz.dll. You don't need to worry about this stuff for your
compiled exe because Quartz.dll is already installed and registered on all
versions of Windows (at least on all versions that I have used).

Anyway, paste in the following code and run the program and click the
button.

Mike

Option Explicit
Private m_objVideoWindow As IVideoWindow
Private m_objMediaControl As IMediaControl
Private Const WS_VISIBLE = &H10000000

Private Function OpenVideo(Filename As String, _
display As PictureBox) As Boolean
display.ScaleMode = vbPixels
OpenVideo = True
On Error GoTo videoNotLoaded
Set m_objMediaControl = New FilgraphManager
Call m_objMediaControl.RenderFile(Filename)
Set m_objVideoWindow = m_objMediaControl
m_objVideoWindow.WindowStyle = WS_VISIBLE
m_objVideoWindow.Top = 0
m_objVideoWindow.Left = 0
m_objVideoWindow.Width = display.ScaleWidth
m_objVideoWindow.Height = display.ScaleHeight
m_objVideoWindow.Owner = display.hWnd
Exit Function
videoNotLoaded:
OpenVideo = False
End Function

Private Sub Command1_Click()
If OpenVideo("c:\temp\kate.mpg", Picture1) Then
m_objMediaControl.Run
Else
MsgBox "Cannot open video file."
End If
End Sub
Lorin
2007-09-22 02:00:02 UTC
Permalink
Trying the Quartz.
Plays wmv.
Does not play the AVI that the mciSendString played.
Need the AVI capability becuase that is what comes off my camera.
Your sample code did not work.
I had other sample Quartz code that does work for wmv.

Is there some tweak to something to tell quartz to accept AVIs ?
I used 'Type MPEGVideo' with mcisendstring to get the AVI to play there.
What's needed for quartz?
Post by Mike Williams
Post by Lorin
Thanks for all the help so far with mciSendString.
. . . . . Works like a champ ... but The last and final
question is . . . . . -
I don't believe that, Lorin! Surely you can't mean that? "The last and final
question"? Sheesh! The last and final question I ask will be the question I
ask immediately before I die! I'm not sure what it will be yet, but it won't
be more than about 15 years away I reckon, and I'm working on it ;-)
Post by Lorin
Now that I can place the video in a PictureBox,
how do I set the size of the video? [big snip] If
I do not use the PictureBox and use the native#
screen, I can drag the corner and get any size video
screen I want. I want the flexibility of the PictureBox
(drag, menu etc). I have looked at the docs and on
newsgroups but cannot find how to tell the mci to set
the video size.
I'm really not very heavily "into" this video stuff, Lorin, but whenever I
want to play a video in VB6 (which admittedly, as an "oldie", is not very
often because we usually "listen to the wireless"!) I use the Active Movie
Type Library, which lives in Quartz.dll and which is installed by default on
all versions of Windows (certainly on all versions from Win98 to Vista) and
which therefore does not require you to distribute anything with your VB6
exe file.
Here is an example which plays a mpg video and which sizes the video to the
current size of the Picture Box. Paste the code into a VB Form containing a
Picture Box and a Command Button. Obviously, you will need to change the
hard coded .mpg path to an .mpg file that exists on your own system.
You will also need to use the VB IDE Project / References menu and scroll
down the list and place a tick against Activemovie control type library. If
you cannot find it in the list then click the "Browse" button and browse to
System32/Quartz.dll. You don't need to worry about this stuff for your
compiled exe because Quartz.dll is already installed and registered on all
versions of Windows (at least on all versions that I have used).
Anyway, paste in the following code and run the program and click the
button.
Mike
Option Explicit
Private m_objVideoWindow As IVideoWindow
Private m_objMediaControl As IMediaControl
Private Const WS_VISIBLE = &H10000000
Private Function OpenVideo(Filename As String, _
display As PictureBox) As Boolean
display.ScaleMode = vbPixels
OpenVideo = True
On Error GoTo videoNotLoaded
Set m_objMediaControl = New FilgraphManager
Call m_objMediaControl.RenderFile(Filename)
Set m_objVideoWindow = m_objMediaControl
m_objVideoWindow.WindowStyle = WS_VISIBLE
m_objVideoWindow.Top = 0
m_objVideoWindow.Left = 0
m_objVideoWindow.Width = display.ScaleWidth
m_objVideoWindow.Height = display.ScaleHeight
m_objVideoWindow.Owner = display.hWnd
Exit Function
OpenVideo = False
End Function
Private Sub Command1_Click()
If OpenVideo("c:\temp\kate.mpg", Picture1) Then
m_objMediaControl.Run
Else
MsgBox "Cannot open video file."
End If
End Sub
Mike Williams
2007-09-22 10:06:45 UTC
Permalink
Post by Lorin
Trying the Quartz.
Plays wmv.
Does not play the AVI that the mciSendString played.
Is there some tweak to something to tell quartz to accept AVIs ?
I used 'Type MPEGVideo' with mcisendstring to get the AVI
to play there.What's needed for quartz?
The Quartz code works fine at this end. Plays AVI files (both stanard AVI
found on my system and AVI from my camera) with no problems at all. Perhaps
it is something to do with your codecs, or perhaps the code I posted needs a
bit more work? I only really "dabble" in this stuff and I don' know very
much about it (which is why I asked for Mike D for more info on MCI in the
previous thread on this subject). I've got other examples on my machine
somewhere. If I get time later (and if any of them appear to work in a
slightly different way) I'll post them. Otherwise, perhaps Mike D might come
back with more details? In the meantime, here's a link to an MSDN page I've
just found about using DirectShow (aka Quartz.dll) with VB6 (although it
also works with VB5).

http://msdn2.microsoft.com/en-us/library/ms787852.aspx

Mike
MikeD
2007-09-22 16:07:54 UTC
Permalink
Post by Lorin
Thanks for all the help so far with mciSendString.
mlRet = mciSendString("open " & sAVIFile & " Type MPEGVideo alias AVI
wait", 0&, 0&, 0&)
Works like a champ ... but
The last and final question is -
Now that I can place the video in a PictureBox, how do I set the size of the
video?
If I do not use the PictureBox and use the native screen, I can drag the
corner and get any size vieo screen I want; I just do not want the Caption
Bar and I want the flexibility of the PictureBox (drag, menu etc).
I have looked at the docs and on newsgroups but cannot find how to tell the
mci to set the video size.
I see a reference to 'stretch' but cannot find details and am not sure if
that is what I want anyway.
Is it possible to set the video size?
I believe it's possible, but I've never attempted to do this. From what I
see, it looks like the "put" MCI command string would be used for this.

http://msdn2.microsoft.com/en-us/library/ms712587.aspx
--
Mike
Microsoft MVP Visual Basic
Mike Williams
2007-09-22 18:42:49 UTC
Permalink
Post by MikeD
[From Lorin] I see a reference to 'stretch' but cannot find
details and am not sure if that is what I want anyway.
Is it possible to set the video size?
I believe it's possible, but I've never attempted to do this. From
what I see, it looks like the "put" MCI command string would be
used for this. http://msdn2.microsoft.com/en-us/library/ms712587.aspx
That's very interesting, Mike, as is the rest of the stuff at that link.
It's all written in MicroSpeak® of course, but I'm sure I'll be able to
translate it into ordinary English given enough time ;-) I can size the
video fine using quartz.dll but it's interesting to see how its done with
MCI commands. Should be able to display just the most interesting parts of
Kate Bush in a fairly large viewing area fairly easily with Put ;-)

Thanks.

Mike

Continue reading on narkive:
Loading...