#include <Sound.au3>
#include <File.au3>
Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 1)
Global $sDir, $aMP3, $iCount, $fPause, $aSound
HotKeySet('{Esc}', '_Exit'); Esc - выход
_Start()
HotKeySet('{F8}', '_Pause'); F8 - пауза в проигрывании
HotKeySet('+{F8}', '_PlayNext'); Shift+F8 - проигрывать следующий файл
While 1
Sleep(500)
WEnd
Func _Pause()
Local $i_Len, $i_Pos
$fPause = Not $fPause
If $fPause Then
AdlibUnRegister('_PlayNext')
TraySetToolTip('(' & $aMP3[0] & ') пауза')
If IsArray($aSound) Then
If Not _SoundPause($aSound) Then
$fPause = False
_Pause()
EndIf
EndIf
Else
If IsArray($aSound) Then
$i_Len = _SoundLength($aSound, 2)
If @error Then _PlayNext()
$i_Pos = _SoundPos($aSound, 2)
If @error Then _PlayNext()
_SoundResume($aSound)
If @error Then _PlayNext()
TraySetToolTip('(' & $aMP3[0] & ') ' & $iCount & ' - ' & $aMP3[$iCount])
AdlibRegister('_PlayNext', $i_Len - $i_Pos + 250)
Else
_PlayNext()
EndIf
EndIf
EndFunc ;==>_Pause
Func _Exit()
If IsArray($aSound) Then
_SoundStop($aSound)
_SoundClose($aSound)
EndIf
Exit
EndFunc ;==>_Exit
Func _PlayNext()
AdlibUnRegister('_PlayNext')
Local $i_Len
If IsArray($aSound) Then
_SoundStop($aSound)
_SoundClose($aSound)
$aSound = 0
EndIf
$iCount += 1
If $iCount > $aMP3[0] Then $iCount = 1
If Not FileExists($sDir & $aMP3[$iCount]) Then _PlayNext()
$aSound = _SoundOpen($sDir & $aMP3[$iCount])
If @error Or @extended Then _PlayNext()
$i_Len = _SoundLength($aSound, 2)
If @error Then _PlayNext()
If Not _SoundPlay($aSound) Then _PlayNext()
TraySetToolTip('(' & $aMP3[0] & ') ' & $iCount & ' - ' & $aMP3[$iCount])
AdlibRegister('_PlayNext', $i_Len + 250)
EndFunc ;==>_PlayNext
Func _Start()
Local $s_Ini = @ScriptDir & '\Info.ini', $s_Mask, $i_Len
$sDir = StringRegExpReplace(IniRead($s_Ini, 'Info', 'Dir', @ScriptDir), '\\*$', '') & '\'
$s_Mask = '*.' & StringRegExpReplace(IniRead($s_Ini, 'Info', 'Files', 'mp3'), '^.*\.', '')
$aMP3 = _FileListToArray($sDir, $s_Mask, 1)
If @error Then
MsgBox(16, 'Error', 'Не найдено файлов ' & $s_Mask & 'в папке ' & $sDir)
Exit
EndIf
_PlayNext()
EndFunc ;==>_Start