How to insert movies/sounds in a Form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to insert movies/sounds in a Form

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    How to insert movies/sounds in a Form

    [Originally posted by rcoltrane]

    I need to insert a movie file in one form with the mpeg, avi or flc extensions. Is there any way to do that? How can I play wav sounds on form/load for example?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:How to insert movies/sounds in a Form

    [Originally posted by Andrea Batina]

    To play the movies you need to load Microsoft Media Player controls from Tools\Components.

    Andrea Batina

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:How to insert movies/sounds in a Form

    [Originally posted by neophile]

    Windows Media Player should be listed in your components.

    Also, to just play a WAV file quickly, just toss this code into a module...

    Option Explicit

    Private Const SND_APPLICATION = &H80 ' look for application specific association
    Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
    Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
    Private Const SND_ASYNC = &H1 ' play asynchronously
    Private Const SND_FILENAME = &H20000 ' name is a file name
    Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
    Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
    Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
    Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
    Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
    Private Const SND_PURGE = &H40 ' purge non-static events for task
    Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
    Private Const SND_SYNC = &H0 ' play synchronously (default)

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

    Public Sub PlayWAV(ByVal WAVFile As String, Optional ByVal Wait As Boolean)
    If Wait Then
    PlaySound WAVFile, ByVal 0&, SND_FILENAME
    Else
    PlaySound WAVFile, ByVal 0&, SND_FILENAME Or SND_ASYNC
    End If
    End Sub


    ...then you can just go...

    Private Sub Form_Load()
    PlayWAV "C:\SomeFolder\somesound.wav"
    End Sub

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:How to insert movies/sounds in a Form

    [Originally posted by rcoltrane]

    Thanks for helping. It works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center