Results 1 to 17 of 17

Thread: Playing AVI Files???

  1. #1

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641

    Question Playing AVI Files???

    Could someone please tell me how to play an AVI File, with great detail??

    Thanks all.
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  2. #2
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    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

  3. #3
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    there is an animation control ( i think its found in the common controls). with this you can play, stop etc avi files
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  4. #4
    Hyperactive Member mvrp350's Avatar
    Join Date
    Feb 2001
    Location
    Best, the Netherlands
    Posts
    322
    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:
    1. 'load the avi file to strTmpFile
    2. Set clsRes = New clsRESFile
    3. clsRes.Load_Res_Data 101, "CUSTOM", "AVI", strTmpPath, strTmpFile
    4.  
    5. 'storing the avi file in aniInProcess
    6. aniInProcess.Open strTmpFile

    and for stopping and unloading

    VB Code:
    1. 'remove temp avi file
    2. Shell App.Path & "\_DelTemp.exe " & strTmpPath, vbHide
    3. 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
    Attached Files Attached Files
    Last edited by mvrp350; Aug 22nd, 2001 at 03:12 AM.

  5. #5

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641

    Hey Libiro!!

    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,
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  6. #6
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    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

  7. #7
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    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

  8. #8
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    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..

  9. #9
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    OK I'm stupid and you're all great

  10. #10
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    No you are not.. I am

  11. #11

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641
    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.

    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  12. #12
    Lively Member
    Join Date
    Sep 1999
    Location
    Huntsville, AR 72740, USA
    Posts
    90

    Unhappy File not found?

    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?
    To Seek is to start on the never ending road to wisdom. To fail to seek, the path to death.

  13. #13
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    can u post the code that u used (the code where u open the file)
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  14. #14
    Lively Member
    Join Date
    Sep 1999
    Location
    Huntsville, AR 72740, USA
    Posts
    90

    Question Code

    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
    To Seek is to start on the never ending road to wisdom. To fail to seek, the path to death.

  15. #15
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    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
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  16. #16
    Lively Member
    Join Date
    Sep 1999
    Location
    Huntsville, AR 72740, USA
    Posts
    90

    Question Success (after a fashion)

    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.
    To Seek is to start on the never ending road to wisdom. To fail to seek, the path to death.

  17. #17
    Member
    Join Date
    Oct 2002
    Posts
    35

    Talking

    Thanks for the code, mvrp350 .

    It really works...i can't do this without you. Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width