Sound

05/02/2012 19:52 osamaman2008#1
hi i need help in sound i know code that code Sound
Code:
#include <Sound.au3>
Local $aSound = _SoundOpen("F:\a\F.mp3")
If @error = 2 Then
	MsgBox(0, "Error", "The file does not exist")
	Exit
ElseIf @extended <> 0 Then
	Local $iExtended = @extended ; Assign because @extended will be set after DllCall.
	Local $tText = DllStructCreate("char[128]")
	DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "ptr", DllStructGetPtr($tText), "int", 128)
	MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
	MsgBox(0, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound, 1)

_SoundClose($aSound)
will work but if i make it F.exe and if i copy the F.exe out Folder the have F.Mp3 don't work i went make it work in any Driver Example D:\a\F.exe went it work F:\a\F.exe went it work E:\a\F.exe went it work G:\a\F.exe went it work C:\a\F.exe went it work can help?
05/02/2012 20:29 K1ramoX#2
FileInstall("F:\a\F.mp3", "F.mp3")

Add this in front of your code.
05/02/2012 20:45 osamaman2008#3
Quote:
Originally Posted by Applecode View Post
FileInstall("F:\a\F.mp3", "F.mp3")

Add this in front of your code.
Thanks you Applecode
it is work :)
;=======================
Applecode can help me again

i i went open Script and the sound play how add it ? Example

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 299, 112, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 24, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd
where i add
Code:
#include <Sound.au3>
Local $aSound = _SoundOpen("F:\a\F.mp3")
If @error = 2 Then
	MsgBox(0, "Error", "The file does not exist")
	Exit
ElseIf @extended <> 0 Then
	Local $iExtended = @extended ; Assign because @extended will be set after DllCall.
	Local $tText = DllStructCreate("char[128]")
	DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "ptr", DllStructGetPtr($tText), "int", 128)
	MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
	MsgBox(0, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound, 1)

_SoundClose($aSound)
FileInstall("F:\a\F.mp3", "F.mp3")
where add it ? to script open and sound play At the same time ?
05/02/2012 21:07 Tobolobo#4
FileInstall should be written after the includes.
Quote:
FileInstall("F:\a\F.mp3", "F.mp3")
Means that the file is being copied to the same folder as the script. The Line
Quote:
Local $aSound = _SoundOpen("F:\a\F.mp3")
has to be changed into
Code:
Local $aSound = _SoundOpen("F.mp3")
Why do you compare @error with 2?
Quote:
If @error = 2 Then
05/02/2012 21:59 *TheWarLords*#5
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 299, 112, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 24, 97, 17)
GUISetState(@SW_SHOW)
Local $aSound = _SoundOpen("F:\a\F.mp3")
_SoundPlay($aSound)
FileInstall("F:\a\F.mp3")
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd
05/03/2012 13:40 K1ramoX#6
Quote:
Originally Posted by *TheWarLords* View Post
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 299, 112, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 24, 97, 17)
GUISetState(@SW_SHOW)
Local $aSound = _SoundOpen("F:\a\F.mp3")
_SoundPlay($aSound)
FileInstall("F:\a\F.mp3")
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd
Srsly wrong. Do it like this:

Code:
#include <Sound.au3>

FileInstall("F:\a\F.mp3")
$aSound = _SoundOpen("F:\a\F.mp3")

$Form1 = GUICreate("Test", 299, 112, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 24, 97, 17)
GUISetState()

_SoundPlay($aSound)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			_SoundClose($aSound)
			Exit

	EndSwitch
WEnd