|
-
Jun 30th, 2002, 09:42 PM
#1
Thread Starter
Hyperactive Member
How to play an AVI file in a specific location using API
Hi,
I want to play an AVI file on my form using the API. I have found some code on AllAPI.net which plays fine, but in another window. I did a search on the web and this site, and found a bas file written by someone here (sorry, can't remember who you are), which promises to play in my form, but doesn't play at all.
Does anyone have a reliable way of doing this?
Thanx for all help
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jun 30th, 2002, 10:06 PM
#2
Junior Member
Play for AVI File
The following TIP may be posted in this site and i hope that you can play *.avi file as per the following tip.
1).Start a new project.
2).Add a Animation Control to the form. (The animation control is part of "Microsoft Windows Common
Controls-2 6.0 in the Project Components list.
3).Add a Command Button (Command1).
4).Paste the following code into the General Declarations section of the Form.
5).Edit the code, looking for the "AVIFile = " statement and make sure it has the correct path to the
"Search.avi" file.
6).Change the statement which reads "Ret = SearchTreeForFile("C:\", "vb6.exe", tempStr)" to
the executable of your choice.
7).Run the program
'------------- PREPARATION END ---------------------------
'------------- CODE --------------------------------------
private Declare Function SearchTreeForFile Lib "imagehlp" (byval RootPath as string, byval InputPathName as string, byval OutputPathBuffer as string) as Long
private Const MAX_PATH = 260
private Sub Command1_Click()
' Note: Search AVI stuff added by me jgd
Dim tempStr as string, Ret as Long
Dim AVIFile as string
'create a buffer string
me.Show
AVIFile = "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos\search.avi"
anmAVI.Open AVIFile
anmAVI.Play
'returns 1 when successfull, 0 when failed
tempStr = string(MAX_PATH, 0)
Ret = SearchTreeForFile("C:\", "vb6.exe", tempStr)
anmAVI.Stop
anmAVI.Close
If Ret <> 0 then
MsgBox "Located file at " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
else
MsgBox "File not found!"
End If
End Sub
-
Jun 30th, 2002, 10:42 PM
#3
Thread Starter
Hyperactive Member
Thanx for the code, but can you tell me why it plays small files like the working.avi (flying folders), but not a movie that i have made?
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jun 30th, 2002, 11:54 PM
#4
-= B u g S l a y e r =-
Re: How to play an AVI file in a specific location using API
Originally posted by Blinky Bill
...are), which promises to play in my form, but doesn't play at all.
have you tried running the sample you found after compiling into an exe ?
I'v seen samples running avi's, not visible in design mode, but works just fine when running as a compiled exe.
just a thought
-
Jul 1st, 2002, 12:42 AM
#5
Thread Starter
Hyperactive Member
Maybe i wasn't clear enough on the reason why it won't play. It gave an error message saying "Type Not Supported when it tried to open the file. So i don't think that compiling will make a difference in this case.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 1st, 2002, 01:22 AM
#6
-
Jul 1st, 2002, 06:11 AM
#7
Addicted Member
codecs maybe ?
Usually, when you create a movie file, you use some sophisticated compression codecs like DivX. If this is the case then :
Maybe the OCX control is not able to use the codecs (decoder) in order to play the AVI.
It could be it, or it could be that the codecs are not registered properly (try Multimedia on Control Panel, or play the movie with Media Player).
Why don't you insert a MediaPlayer control in your form ? It will be playing right, but you will have to distribute the OCX of course, which sucks...
-
Jul 1st, 2002, 06:46 AM
#8
You could use the mciSendString API to play movies.
Have a look at this thread for the basics
-
Jul 1st, 2002, 05:15 PM
#9
Fanatic Member
I once had a class module that plays avi's into a specified hwnd, it was really cool but that was like 3 years ago and i dont have it know more. But I found it on www.pscode.com and im sure it used mcisendstring as mention above
-
Jul 1st, 2002, 05:19 PM
#10
Fanatic Member
umm sorry but planet source code seems to not work no more!
-
Jul 1st, 2002, 06:00 PM
#11
Thread Starter
Hyperactive Member
Just to clarify a few points: I don't want to use an OCX to play it, the code i dug up off allApi.net worked (with a few little bugs) using mcisendstring, but played in a separate window rather than the creating form. The bas file i dug up used mcisendstring combined with the form handle to play in, but wouldn't/couldn't open the avi, except for little ones.
Thanx all for looking at this.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Jul 2nd, 2002, 01:58 AM
#12
I still recommend mciSendString.
If you don't want it to open a new window, specify the parent in the open command.
Use the type Sequencer for .mid files, waveaudio for .wav files, CDAudio for .cda files and use MPEGvideo for all the others. Don't use the type AVIVideo for .avi files, the MPEGVideo type yields better results.
eg
mciSendString "open " & strFileToPlay & "alias MyVideo type MPEGVideo parent " & Picture1.hwnd, 0, 0, 0
-
Sep 3rd, 2002, 10:23 PM
#13
Lively Member
playing avi and wav together
how about playing an avi and wav file together...is it possible?
so far I have an avi file which the sound file is actually in other file
test.avi and test.wav
do you think I can play both files simutaneously ?..how do I synchronise both files?
-
Sep 4th, 2002, 11:47 AM
#14
Hyperactive Member
Ok, I'm using MciSendString to play avi files. I have a similar to problems that I've scoped out over the forum and haven't found an answer to. Bear in mind that I'm using VBA and that is not compileable (I think). How do you get around the size limit for playing avi files? If I play a small one, no problem. Pick a larger one and I get 'The Driver can not recognize the specified command parameter' and yet I've changed nothing but the file. I'm using some code I found on the forum:
VB Code:
Public Sub PlayVideo(FilePath As String, PlayIn As Long)
FilePath = UCase(FilePath)
If Right(FilePath, 3) = "AVI" Then
longnum = mciSendString("open " & FilePath & " type Avivideo alias movie style child parent " & PlayIn, 0&, 0, 0)
If longnum <> 0 Then DisplayError longnum
Else
mciSendString "open " & FilePath & " type MPEGvideo alias movie style child parent " & PlayIn, 0&, 0, 0
End If
mciSendString "play movie wait", 0, 0, 0
mciSendString "close movie", 0, 0, 0
End Sub
Any help would be appreciated.
-
Sep 4th, 2002, 01:36 PM
#15
I had similar problems when I used type Avivideo for *.avi files.
Try using MPEGvideo for avi files as well.
To quote myself
Use the type Sequencer for .mid files, waveaudio for .wav files, CDAudio for .cda files and use MPEGvideo for all the others. Don't use the type AVIVideo for .avi files, the MPEGVideo type yields better results.
-
Sep 4th, 2002, 01:55 PM
#16
Hyperactive Member
Actually that's what I'm using. The one file is 83K and plays fine. The other is 5 megs and doesn't play at all. Any other ideas?
The code I posted is a little older and I'm using MPEGVideo in both circumstances now. Sorry for the confusions. But it's still not working...
-
Sep 5th, 2002, 12:48 AM
#17
I have no problems using MPEGVideo, even if the file is 700 MB.
Of course you need to have the proper codec installed.
Can you play the movie with another player?
-
Sep 5th, 2002, 08:16 AM
#18
Hyperactive Member
If I use the mplayer it works fine. Just not when I try to launch it with MCISendString. I don't get it. I'm using WINNT and this is in VBA if that makes a difference..
-
Sep 5th, 2002, 09:02 AM
#19
Why do you specify style child if you also specify a parent? I don't know if this has anything to do with the problem you have, but it seems a contradiction.
From MSDN:
parent hwnd - Specifies the window handle of the parent window.
style child - Opens a window with a child window style.
Another possible reason for this error is a space in the path or filename. To avoid this problem, enclose the path and filename in double quotes.
eg.
mciSendString "open " & Chr(34) & FilePath & Chr(34) & " type MPEGvideo alias movie style child parent " & PlayIn, 0&, 0, 0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|