Post by nnnik » 23 Aug 2017, 11:41
Um eine einfache Sounddatei zu laden genügt ein Code wie:
Code: Select all
UrlDownloadToFile, https://cdn.discordapp.com/attachments/115993023636176902/339539250020089857/bass.dll, bass.dll
UrlDownloadToFile, https://cdn.discordapp.com/attachments/115993023636176902/339539756851396608/somebody.mp3, somebody.mp3
if !DllCall("LoadLibrary", "Str", "bass.dll")
ErrorExit( "failed to load bass.dll" )
if !DllCall( "bass.dll\BASS_Init"
, "UInt", Device := -1 ;a number to specify which output you want to use. use -1 for default
, "UInt", Frequency := 44100 ;a number to specify the frequency you want to output with
, "UInt", Flags := 0 ; a combination of options
, "UInt", window := 0 ;The window the program uses ( leave 0 for none )
, "UPtr", 0 ) ;
ErrorExit( "failed to initialize device" )
vFile = somebody.mp3
Gui, Font, s16 c333333 norm
Gui, Add, Text, text1 x10 y10 ReadOnly Lowercase Left, Test
Gui, Font, s12 norm
Gui, Add, Button, gsButton w88 h44 x102 y100 vBYes, Confirm
Gui, -MinimizeBox -MaximizeBox
Gui, Show, w1154 h869, SoundBoard Switcher
sPlaceHolder:
return
sButton:
Gui, Submit, NoHide
PlaySong(vfile)
return
GuiClose:
ExitApp
return
PlaySong(vFile)
{
static stream
if stream
{
DllCall( "bass.dll\BASS_ChannelStop", "UInt", stream )
DllCall( "bass.dll\BASS_StreamFree", "UInt", stream )
}
if !stream := DllCall("bass.dll\BASS_StreamCreateFile","UInt",0,"WStr",vFile,"UInt64",0,"UInt64",0,"UInt",0x80000000)
ErrorExit( "failed to initialize stream" )
if !DllCall("bass.dll\BASS_ChannelPlay","UInt",Stream,"Int",0)
ErrorExit( "failed to play stream" )
}
ErrorExit( msg )
{
Msgbox % "Error:" . msg . "`nErrorCode:" . DllCall( "bass.dll\BASS_ErrorGetCode" ) . "`nErrorLevel:" . ErrorLevel . "`nA_LastError:" . A_LastError . "`nA_WorkingDir" . A_WorkingDir . "`nA_PtrSize:" . A_PtrSize . "`nA_AHKVerison" . A_AHKVersion
ExitApp, -1
}
Um eine einfache Sounddatei zu laden genügt ein Code wie:
[code]UrlDownloadToFile, https://cdn.discordapp.com/attachments/115993023636176902/339539250020089857/bass.dll, bass.dll
UrlDownloadToFile, https://cdn.discordapp.com/attachments/115993023636176902/339539756851396608/somebody.mp3, somebody.mp3
if !DllCall("LoadLibrary", "Str", "bass.dll")
ErrorExit( "failed to load bass.dll" )
if !DllCall( "bass.dll\BASS_Init"
, "UInt", Device := -1 ;a number to specify which output you want to use. use -1 for default
, "UInt", Frequency := 44100 ;a number to specify the frequency you want to output with
, "UInt", Flags := 0 ; a combination of options
, "UInt", window := 0 ;The window the program uses ( leave 0 for none )
, "UPtr", 0 ) ;
ErrorExit( "failed to initialize device" )
vFile = somebody.mp3
Gui, Font, s16 c333333 norm
Gui, Add, Text, text1 x10 y10 ReadOnly Lowercase Left, Test
Gui, Font, s12 norm
Gui, Add, Button, gsButton w88 h44 x102 y100 vBYes, Confirm
Gui, -MinimizeBox -MaximizeBox
Gui, Show, w1154 h869, SoundBoard Switcher
sPlaceHolder:
return
sButton:
Gui, Submit, NoHide
PlaySong(vfile)
return
GuiClose:
ExitApp
return
PlaySong(vFile)
{
static stream
if stream
{
DllCall( "bass.dll\BASS_ChannelStop", "UInt", stream )
DllCall( "bass.dll\BASS_StreamFree", "UInt", stream )
}
if !stream := DllCall("bass.dll\BASS_StreamCreateFile","UInt",0,"WStr",vFile,"UInt64",0,"UInt64",0,"UInt",0x80000000)
ErrorExit( "failed to initialize stream" )
if !DllCall("bass.dll\BASS_ChannelPlay","UInt",Stream,"Int",0)
ErrorExit( "failed to play stream" )
}
ErrorExit( msg )
{
Msgbox % "Error:" . msg . "`nErrorCode:" . DllCall( "bass.dll\BASS_ErrorGetCode" ) . "`nErrorLevel:" . ErrorLevel . "`nA_LastError:" . A_LastError . "`nA_WorkingDir" . A_WorkingDir . "`nA_PtrSize:" . A_PtrSize . "`nA_AHKVerison" . A_AHKVersion
ExitApp, -1
}[/code]