Could someone please tell me how to play an AVI File, with great detail??
Thanks all.
Printable View
Could someone please tell me how to play an AVI File, with great detail??
Thanks all.
With the Microsoft multimedia control (Project/Components), and a commandbutton.
Private Sub Command1_Click()
MMControl1.Command = "close"
MMControl1..DeviceType = "AVIVideo"
MMControl1..FileName = "path and filename here"
MMControl1..Command = "open"
MMControl1..Command = "Play"
End Sub
there is an animation control ( i think its found in the common controls). with this you can play, stop etc avi files
First add in the resource manager the AVI file as a custom file.
next add 2 class modules:
added in the zip file
next for playing the AVI:
VB Code:
'load the avi file to strTmpFile Set clsRes = New clsRESFile clsRes.Load_Res_Data 101, "CUSTOM", "AVI", strTmpPath, strTmpFile 'storing the avi file in aniInProcess aniInProcess.Open strTmpFile
and for stopping and unloading
VB Code:
'remove temp avi file Shell App.Path & "\_DelTemp.exe " & strTmpPath, vbHide Set clsRes = Nothing
obviously you need an animation control on your form.
The big advantage of using it this way is you don't need to worry about redistributing your app AND your avi-file, because it's included in the executable.
There's a file needed to remove the temporary file it's called _DelTemp.exe and is attached to this post.
BTW: Many thanks to Kenneth Ives who came up with this code
Thanks, your code worked great, but how do I get it to play in non-fullscreen mode. I want it to play a movie like windows media player.
Thanks,
Without the MMcontrol: (add a picturebox)
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
hwndCallback As Long) As Long
Private Sub Command1_Click()
' U can also use Form1.hwnd instead of Picture1.hwnd
Last$ = Picture1.hWnd & " Style " & &H40000000
ToDo$ = "open C:\Myavi.avi Type avivideo Alias video parent " & Last$
x% = mciSendString(ToDo$, 0&, 0, 0)
x% = mciSendString("put video window at 0 0 210 210", 0&, 0, 0)
x% = mciSendString("play video wait", 0&, 0, 0)
x% = mciSendString("close video", 0&, 0, 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
x% = mciSendString("close video", 0&, 0, 0)
End Sub
Getting back to Beasty1711's suggestion:
Components: Microsoft Windows Common Controls 2 5.0 or 6.0
The animation control can then be used as follows:
Open an avi file
Form1.Animation1.Open "<Pathname here>"
Play - repeats forever if no options specified
Form1.Animation1.Play [number of times to repeat], [start frame], [End frame]
Stop
Form1.Animation1.Stop
Close
Form1.Animation1.Close
Nice easy code :D
This is from the msdn help:
<If you attempt to load an .avi file that includes sound data or that is in a format not supported by the control, an error (error 35752) is returned.>
Soo! If you got a file with sounds you can´t use SjR´s code..
OK I'm stupid and you're all great :rolleyes:
No you are not.. I am :D
I tried using Liberos idea, but It still displayed in fullscreen..
I think it is because I am using VB 5.0
I will upgrade soon... how can I do it in VB 5.0???
Thanks Libero and all others who have helped so far.
:)
I tried using SJR's code for the animation control. I got error '53' - File not found. I know the file is there. Anyone have any suggestions on why it wouldn't be able to find the file?
can u post the code that u used (the code where u open the file)
The code is simple and straight-forward since this is more of a test than anything else.
Option Explicit
Dim FNames as String
Private Sub Command1_Click()
FNames = App.Path & "\Growing Mountains"
Form1.Animation1.Open FNames
Form1.Animation1.Play
End Sub
you need to put .avi on the end of your path, also i recommend
that u rename the file so that there are no spaces in the title
Adding .avi seems to have handled the problem. But apparently, when Poser creates an AVI there is an assumed audio component. So the animation control gives me the '35752' error that Libero mentioned.
I tried the MMControl that Libero talks about at the beginning of this post... But while it apparently runs (no errors) I also don't see any video.
Thanks for the code, mvrp350 .
It really works...i can't do this without you. Thanks a lot.