Locked How to show short movie repeatedly?

  • Tuesday, September 04, 2007 12:34 AM
     
     

    Hi,

     

    I want to show a short movie repeatedly in my program and I want to know if it can be

    in a "picturebox"? if it can how? and if not how can I do this in otherway?

     

    Best Regards,

    Yaniv

All Replies

  • Tuesday, September 04, 2007 12:51 AM
     
     

    What sort of movie? And easier move (if possible) would be to simply use an animated gif and load simply point the PictureBox's Image property at it.

  • Tuesday, September 04, 2007 9:28 AM
     
     

    short movie like *.avi and I want it repeatedly?

     

    Is this tesk take a lot of the cpu percentage?

     

     

  • Tuesday, September 04, 2007 3:56 PM
     
     Answered

    Ahh, you are best served to look into doing so with DirectX then.

     

    Playing any kind of video file will take up more CPU time than a static image yes, however using CPU time isn't always a bad thing, it just depends on what you are using it for and how it affects the user.

  • Wednesday, September 05, 2007 10:10 PM
     
     

     

    Thanks...

    But I saw that the examples are for C do you have some example for VB2005?

  • Thursday, September 06, 2007 9:18 AM
     
     Answered

    Hi Yanivpinhas,

    I have converted the demo application inside the following document that Brendan mentioned to the corresponding VB.NET edition. It works fine. If you need the completed VB.NET solution, please tell me your Email, I will send it to you. 

    Playing AVI Files using DirectX 9 with C# and .NET

    Code snippet in Form1.vb

    Imports Microsoft.VisualBasic

    Imports System

    Imports System.Drawing

    Imports System.Collections

    Imports System.ComponentModel

    Imports System.Windows.Forms

    Imports System.Data

    Imports Microsoft.DirectX.AudioVideoPlayback

    Namespace PlayAVI

              Public Class Form1

                       Inherits System.Windows.Forms.Form

     

                       <STAThread> _

                       Shared Sub Main()

                                 Application.Run(New Form1())

                       End Sub

                       Private Sub ControlLogic()

                                 If _video Is Nothing Then

                                          btnPlay.Enabled = False

                                          btnStop.Enabled = False

                                          btnPause.Enabled = False

                                          chkFullScreen.Enabled = False

                                 Else

                                          btnPlay.Enabled = True

                                          btnStop.Enabled = True

                                          btnPause.Enabled = True

                                          chkFullScreen.Enabled = True

                                 End If

                       End Sub

                       Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.Click

                                 If Not _video Is Nothing Then

                                          _video.Play()

                                 End If

                       End Sub

                       Private Sub btnPause_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPause.Click

                                 If Not _video Is Nothing Then

                                          _video.Pause()

                                 End If

                       End Sub 

                       Private Sub btnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStop.Click

                                 If Not _video Is Nothing Then

                                          _video.Stop()

                                 End If

                       End Sub

                       Private Sub OpenVideo()

                                 openFileDialog1.InitialDirectory = Application.StartupPath

                          If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then           

                                          Dim height As Integer = videoPanel.Height

                                          Dim width As Integer = videoPanel.Width

                                          If Not _video Is Nothing Then

                                                    _video.Dispose()

                                          End If

                                          _video = New Video(openFileDialog1.FileName)

                                          _video.Owner = videoPanel

                                          videoPanel.Width = width

                                          videoPanel.Height = height

                                          _video.Play()

                                          _video.Pause()

                                 End If

                                 ControlLogic()

                       End Sub

                       Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpen.Click

                                 OpenVideo()

                       End Sub

                       Private Sub chkFullScreen_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkFullScreen.CheckedChanged

                                 If Not _video Is Nothing Then

                                          _video.Fullscreen = chkFullScreen.Checked

                                 End If

                       End Sub

              End Class

    End Namespace

    Regards,

    Martin

  • Thursday, September 06, 2007 9:22 AM
     
     

    By the way, you can convert C# code to VB.NET code by means of this Code Translator tool.

  • Thursday, September 06, 2007 10:24 AM
     
     

    Ok.. thank you.... I will look at that in few hours.

     

     

  • Saturday, September 08, 2007 12:58 PM
     
     

    I have some problem with that... can you send me please the completed VB.NET solution

    my email is: y_pinhas@hotmail.com

     

    Thank you...

     

     

  • Saturday, September 08, 2007 10:51 PM
     
     

    If you can tell me please after you sent it...

  • Sunday, September 09, 2007 4:42 AM
     
     

    Hi Yanivpinhas,

     

    Thank you for contacting me.

     

    That VB.NET project has been sent to your mailbox: y_pinhas@hotmail.com.

     

    Please run/preview the result and view the code.

     

     

    Best wishes,

    Martin

  • Friday, November 16, 2007 11:41 PM
     
     

    I could really use the complete VB.net version... ed.thompson@verizon.net

     

    Thanks,

     

    EdT

     

  • Monday, November 19, 2007 1:57 AM
     
     

    Errata:

     

    The following additional code may be needed

    to make the video loop.

     

     

    AddHandler m_Video.Ending, AddressOf Me.VideoEnds

     

     

      Private Sub VideoEnds(ByVal sender As Object, ByVal e As System.EventArgs)
            ' The following line causes the song to loop.
            ' You can surround it with an
            ' If check box checked bla bla bla ... Then...
            ' To make the loop function optional
          
                m_Video.CurrentPosition = 0
         
        End Sub

     

  • Monday, November 19, 2007 2:08 AM
     
     
     Ed Thompson wrote:

    I could really use the complete VB.net version... ed.thompson@verizon.net

    Hi EdT,

    The complete VB.net version has been sent to your mailbox.

  • Monday, November 19, 2007 2:21 AM
     
     

    Another point of interest.

     

    I played around with the code that Martin posted,

    a month or two ago, and implemented a different

    way of making the video fullscreen than using

    the _Video.fullscreen property.

     

    When fullscreen (in my way of doing it,)

     I was testing

    keypresses to ultimately make the escape key send

    you back to non-fullscreen.

    What I did not realize is that the m_video object does

    not act like a regular control.

     When it was running fullscreen,

    it did not actually have the focus.

    I kept wondering why my program acted funny when I hit

    the spacebar while fullscreen.

    What was happening was that the focus was still on the

    Play/Stop button, and the spacebar was causing the button

    to click.

    (A 'feature' I was unaware of.)

    Anyway, I got around the problem by adding the code below

    in the Play/Stop button click event.

     

    ' keep the spacebar from 'clicking' the button

    If e Is EventArgs.Empty Then

    Exit Sub

    End If

     

     

  • Monday, November 19, 2007 7:07 AM
     
     

    Excellent!  Martin, I did get the origional code to work but I really appreciate your response.

     

    Tall Dude:  One of the first issues that I came accross was how to exit from the full screen mode.  I was having to shut down the program.  So, your comments were very helpful.  

     

    This should probably be a differenent post but one approach that I was looking into was to assign different keyboard keys, (ie. F1, F2... etc.)  to different avi tracks and functions.  Then while in the full screen mode, various keyboard "hot keys" could be used.  I knew how to "manage" keyboard keys back in VB6 but have had not found how to translate this over to .net yet.  Does anyone know how to do this?

     

    Thanks,

     

    EdT

  • Monday, November 19, 2007 6:27 PM
     
     

    I was able to implement the escape key to exit

    fullscreen in my code.

     

    I also setup context menus.

     

    Download the code I was playing around with

    at http://www.filecrunch.com/file/~3qxv80

     

  • Tuesday, March 25, 2008 2:39 PM
     
     

    Martin Xie

    I have written a short VB prog using Directx.AudioVideoPlayback to display an AVI file of my own making.  I converted it to a screen saver and it works fine except it only plays through once and stops.  Is there a quick fix for this or do I need to use your code snippet

     

    Briggscoverd@aol.com

     

  • Sunday, March 30, 2008 6:20 PM
     
     

    Martin

    I would also like a copy of the complete code

    Thanks

    briggscoverd@aol.com

  • Monday, March 31, 2008 2:15 AM
     
     
    Thank you Billcoke for contacting me. The VB.NET sample project has been sent to your mailbox. Please check it.
  • Thursday, October 27, 2011 4:02 PM
     
     

    Hi there

    this threat looks very intresting and might solve the problem i am stucked on at the moment.

    any chance that someone of you still have the VB.NET sample project that could be forwarded to me?

    my mail is gregor@toggwyler.ch