Thanks for sharing. hi to all of you. Please excuse my English (thanks Google translator!). I noticed that the libZPlay.au3 file only allows playback / manipulation of one piece of music at a time. If you open and play another piece of music while the first one is playing, the script stops and crashes. Therefore I have modified the same file so that it is possible to execute more instances to CreateZPlay() in order to be able to perform more music at the same time (for example to cross a few seconds of the end of a song with the beginning of the other). In a hurry I made the change and a short script that plays two songs that can be heard simultaneously.
Basically the modification to the libZPlay.au3 file consists in commenting or removing the Global $ZPLAY_HANDLE = 0 (Global $ZPLAY_HANDLE = 0 ----->; ~ Global $ZPLAY_HANDLE = 0) line and modify the CreateZPlay() function in this way: Func CreateZPlay()
$LibZplay = DllOpen ($LibZplayName)
Local $Ret = DllCall ($LibZplay, 'DWORD', 'zplay_CreateZPlay')
If @error Then Return SetError (@error, @extended, 0) ; ~ $ZPLAY_HANDLE = $ Ret [0]
Return $ Ret [0]
EndFunc; ==> CreateZPlay
that is, to have make $Ret [0] return the instance handle.
in the test script $Song1 and $Song2 have different handles. By passing these handles to the internal functions of libZPlay.au3, modified appropriately, we can manage the music pieces independently.
mylibzplayExample.au3:
#include 'LibZPlay_MOD.au3'
Local $hSong1 = CreateZPlay()
Local $hSong2 = CreateZPlay()
ConsoleWrite ("$hSong1: " & $hSong1 & @TAB & "$hSong2: " & $hSong2 & @LF)
Local $sCurrentFile1 = FileOpenDialog ('Select your File', @ScriptDir, 'Supported Files (*. Mp3; *. Mp2; *. Mp1; *. Ogg; *. Flac; *. Oga; *. Wav; *. Ac3 ; *. aac) ')
OpenFile ($sCurrentFile1, $ sfAutodetect, $hSong1)
Play ($hSong1)
Local $ sCurrentFile2 = FileOpenDialog ('Select your File', @ScriptDir, 'Supported Files (*. Mp3; *. Mp2; *. Mp1; *. Ogg; *. Flac; *. Oga; *. Wav; *. Ac3 ; *. aac) ')
OpenFile ($ sCurrentFile2, $ sfAutodetect, $hSong2)
Play ($hSong2)
Sleep (10000)
Close ($hSong1)
DestroyZPlay ($hSong1)
Sleep (10000)
Close ($hSong2)
DestroyZPlay ($hSong2)
libZPlay_MOD.au3
my_libzPlayExample.au3