#include <Audio.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $IniFile = @ScriptDir & "\txt.txt"
Dim $Item[1]
Dim $pot = ""
Dim $soundLoad_id, $click_id
Global Const $DebugIt = 1
Dim $TotalSounds = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ListView", 167, 311, -1, -1)
$Combo1 = GUICtrlCreateCombo("", 8, 24, 145, 25)
$lvs1 = GuiCtrlCreateListView("编号|歌曲名称|歌曲路径",8,56, 140, 214)
$Button1 = GUICtrlCreateButton("播放", 48, 280, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var = IniReadSectionNames($IniFile)
If @error Then
Else
For $i = 1 To $var[0]
$pot = $pot & "|" & $var[$i]
Next
GUICtrlSetData($Combo1, StringMid ($pot, 1), $var[1])
EndIf
If FileExists($IniFile) Then
Local $List = IniReadSection($IniFile, "第一组")
For $i = 1 To $List[0][0]
$New_ID = UBound($Item) + 1
ReDim $Item[$New_ID]
$AllSound_ID = $i
$Item[$New_ID - 1] = $List[$i][1]
$TotalSounds = $TotalSounds + 1
$bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i][0] & "|" & $List[$i][1], $lvs1)
If Round($I / 2) = $I / 2 Then GUICtrlSetBkColor($bjys, 0xEEEEEE)
Next
EndIf
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
_GUICtrlListView_DeleteAllItems($lvs1)
If FileExists($IniFile) Then
Local $List = IniReadSection($IniFile, GUICtrlRead($Combo1))
For $i = 1 To $List[0][0]
$New_ID = UBound($Item) + 1
ReDim $Item[$New_ID]
$AllSound_ID = $i
$Item[$New_ID - 1] = $List[$i][1]
$TotalSounds = $TotalSounds + 1
$bjys=GUICtrlCreateListViewItem($i & "|" & $List[$i][0] & "|" & $List[$i][1], $lvs1)
If Round($I / 2) = $I / 2 Then GUICtrlSetBkColor($bjys, 0xEEEEEE)
Next
EndIf
Case $Button1
EndSwitch
WEnd
Func myplay($in_id)
_SoundStop($soundLoad_id)
$play_ID = $in_id
_GuiCtrlListView_SetItemSelected ($lvs1, ($play_ID - 1))
$aItem2 = _GUICtrlListView_GetItemTextArray ($lvs1, ($play_ID - 1))
$soundLoad_id = _SoundOpen($Item[$play_ID])
MsgBox(0,"播放歌曲",$aItem2[2]&$Item[$play_ID])
_SoundPlay($soundLoad_id)
$aItem2 = _GUICtrlListView_GetItemTextArray ($lvs1, ($play_ID - 1))
AdlibEnable("display", 1000)
EndFunc
Func display()
Local $ptime, $totaltime
$ptime = _SoundPos($soundLoad_id)
$totaltime = _SoundLength($soundLoad_id)
If $ptime = $totaltime Then
$play_ID = $play_ID + 1
If $play_ID >= UBound($Item) Then $play_ID = 1
myplay($play_ID)
EndIf
EndFunc
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
Select
Case $wParam = $lvs1
Select
Case $event = $NM_CLICK
ListView_Click()
Case $event = $NM_DBLCLK
ListView_DoubleClick()
EndSelect
EndSelect
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc ;==>WM_Notify_Events
Func ListView_Click()
If $DebugIt Then _DebugPrint("$NM_CLICK")
EndFunc
Func ListView_DoubleClick()
If $DebugIt Then _DebugPrint("$NM_DBLCLK")
$click_id = Number(_GUICtrlListView_GetSelectedIndices ($lvs1)) + 1
myplay($click_id)
EndFunc
Func _DebugPrint($s_text)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc