473,392 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,392 software developers and data experts.

Need to know the VB code of how to stop Playing sound through a click button

Hi All;

Please, if any one knows the visual basic code, to be added to a Stop button in order to stop playing some sound of (*.Wav) type. I have achieved to find the code for start playing sound or music which is:

OLE.DoVerb (vbOLEPrimary)

But the one to stop or interupt the sound I could not find it.

Please let know

Thank you in advance

M C Benzerari
Aug 7 '07 #1
4 5035
Dököll
2,364 Expert 2GB
Hi All;

Please, if any one knows the visual basic code, to be added to a Stop button in order to stop playing some sound of (*.Wav) type. I have achieved to find the code for start playing sound or music which is:

OLE.DoVerb (vbOLEPrimary)

But the one to stop or interupt the sound I could not find it.

Please let know

Thank you in advance

M C Benzerari
Give this a whirl, Benzerari:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim app_path As String
  4.  
  5.     app_path = App.Path
  6.     If Right$(app_path, 1) <> "\" Then app_path = app_path _
  7.         & "\"
  8.     txtFile.Text = app_path & "Alice_Cooper-Gimmie.mp3"
  9.  
  10.     ' Prepare the audio control.
  11.     mmcAudio.Notify = False
  12.     mmcAudio.Wait = True
  13.     mmcAudio.Shareable = False
  14.     mmcAudio.Command = "Close"
  15. End Sub
  16.  
  17. ' Play the MP3 file.
  18. Private Sub cmdPlay_Click()
  19.     If cmdPlay.Caption = "Play" Then
  20.         mmcAudio.FileName = txtFile.Text
  21.         mmcAudio.Command = "Open"
  22.         mmcAudio.Command = "Play"
  23.         cmdPlay.Caption = "Stop"
  24.     Else
  25.         mmcAudio.Command = "Stop"
  26.         mmcAudio.Command = "Close"
  27.     End If
  28. End Sub
  29.  
  30. Private Sub mmcAudio_StatusUpdate()
  31.     lblAudio.Caption = mmcAudio.Position & "/" & _
  32.         mmcAudio.Length
  33. End Sub
  34.  
  35. ' Prepare the control to play again.
  36. Private Sub mmcAudio_Done(NotifyCode As Integer)
  37.     mmcAudio.Command = "Close"
  38.     lblAudio.Caption = ""
  39.     cmdPlay.Caption = "Play"
  40. End Sub
  41.  
  42. Private Sub Form_Unload(Cancel As Integer)
  43.     ' Close the multimedia device.
  44.     mmcAudio.Command = "Close"
  45. End Sub
  46.  
  47.  
Hopefully this is what you wanted. Let us know if it works, just found this one...
Aug 8 '07 #2
Give this a whirl, Benzerari:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim app_path As String
  4.  
  5.     app_path = App.Path
  6.     If Right$(app_path, 1) <> "\" Then app_path = app_path _
  7.         & "\"
  8.     txtFile.Text = app_path & "Alice_Cooper-Gimmie.mp3"
  9.  
  10.     ' Prepare the audio control.
  11.     mmcAudio.Notify = False
  12.     mmcAudio.Wait = True
  13.     mmcAudio.Shareable = False
  14.     mmcAudio.Command = "Close"
  15. End Sub
  16.  
  17. ' Play the MP3 file.
  18. Private Sub cmdPlay_Click()
  19.     If cmdPlay.Caption = "Play" Then
  20.         mmcAudio.FileName = txtFile.Text
  21.         mmcAudio.Command = "Open"
  22.         mmcAudio.Command = "Play"
  23.         cmdPlay.Caption = "Stop"
  24.     Else
  25.         mmcAudio.Command = "Stop"
  26.         mmcAudio.Command = "Close"
  27.     End If
  28. End Sub
  29.  
  30. Private Sub mmcAudio_StatusUpdate()
  31.     lblAudio.Caption = mmcAudio.Position & "/" & _
  32.         mmcAudio.Length
  33. End Sub
  34.  
  35. ' Prepare the control to play again.
  36. Private Sub mmcAudio_Done(NotifyCode As Integer)
  37.     mmcAudio.Command = "Close"
  38.     lblAudio.Caption = ""
  39.     cmdPlay.Caption = "Play"
  40. End Sub
  41.  
  42. Private Sub Form_Unload(Cancel As Integer)
  43.     ' Close the multimedia device.
  44.     mmcAudio.Command = "Close"
  45. End Sub
  46.  
  47.  
Hopefully this is what you wanted. Let us know if it works, just found this one...
Thank you very much for this reply, I did know it is so long like that, the code to start play some sound of ( .WAV ) type, uses OLE control, I though it is similar for stoping it too?

but any way I am going to try it and let you know

Thank you

M C Benzerari
Aug 8 '07 #3
Sorry! I wanted to say:

Thank you very much for this reply, I did NOT know it is so long like that, the code to start play some sound of ( .WAV ) type, uses OLE control, I though it is similar for stoping it too?

but any way I am going to try it and let you know


As there is no way to correct a thread once added...

Thank you

M C Benzerari
Aug 9 '07 #4
Give this a whirl, Benzerari:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim app_path As String
  4.  
  5.     app_path = App.Path
  6.     If Right$(app_path, 1) <> "\" Then app_path = app_path _
  7.         & "\"
  8.     txtFile.Text = app_path & "Alice_Cooper-Gimmie.mp3"
  9.  
  10.     ' Prepare the audio control.
  11.     mmcAudio.Notify = False
  12.     mmcAudio.Wait = True
  13.     mmcAudio.Shareable = False
  14.     mmcAudio.Command = "Close"
  15. End Sub
  16.  
  17. ' Play the MP3 file.
  18. Private Sub cmdPlay_Click()
  19.     If cmdPlay.Caption = "Play" Then
  20.         mmcAudio.FileName = txtFile.Text
  21.         mmcAudio.Command = "Open"
  22.         mmcAudio.Command = "Play"
  23.         cmdPlay.Caption = "Stop"
  24.     Else
  25.         mmcAudio.Command = "Stop"
  26.         mmcAudio.Command = "Close"
  27.     End If
  28. End Sub
  29.  
  30. Private Sub mmcAudio_StatusUpdate()
  31.     lblAudio.Caption = mmcAudio.Position & "/" & _
  32.         mmcAudio.Length
  33. End Sub
  34.  
  35. ' Prepare the control to play again.
  36. Private Sub mmcAudio_Done(NotifyCode As Integer)
  37.     mmcAudio.Command = "Close"
  38.     lblAudio.Caption = ""
  39.     cmdPlay.Caption = "Play"
  40. End Sub
  41.  
  42. Private Sub Form_Unload(Cancel As Integer)
  43.     ' Close the multimedia device.
  44.     mmcAudio.Command = "Close"
  45. End Sub
  46.  
  47.  
Hopefully this is what you wanted. Let us know if it works, just found this one...
Please can you send me a sketch of how the form related to the above code looks like, with enough details,...also you can send it as an attachement to benzerari1966@yahoo.com. as there is no way to attach it in the forum

Thank you

M C Benzerari
Aug 9 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MLH | last post by:
Edit, Insert Object & choose Wave Object, the following OLE object thing gets inserted onto the form... Microsoft Sound Recorder Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)...
5
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function...
7
by: Lee Moody | last post by:
I just want quick and easy way to play a .wav file out the standard sound device. It could even be as simple as activating a sound assigned to an existing windows sound event. Any suggestions?...
13
by: James Bond | last post by:
Hello. My 80+ year old father has recently decided to get his first computer. Due to his age (and I suspect lack of playing pong as a child like I did) he lacks the manual dexterity to use a mouse...
4
by: Fredrik Melin | last post by:
If you open a form, add a button, double click on the button, you now enter the code for the button click event. If you switch back to the form, and remove the button, it will also remove the...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
6
by: laredotornado | last post by:
Hi, Is there a cross-browser way to play short (< 25K) sound files without spawning new windows or embedding any visual controls on the page? I would like to click a button and hear my short...
6
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.