本帖最后由 shenrenba 于 2010-11-24 12:07 编辑
#include <INet.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $musicdq = 0 ;当前播放的音乐
Global $musiczs = 1 ;音乐总数目
$Form1 = GUICreate("TEST", 623, 449, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Label1 = GUICtrlCreateLabel("", 72, 40, 388, 33)
$Button1 = GUICtrlCreateButton("上一首", 72, 104, 113, 41)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("下一首", 311, 103, 113, 41)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
$musicinfo = _Source("http://www.songtaste.com/radio.php")
play($musicinfo[$musicdq][0], $musicinfo[$musicdq][1], $musicinfo[$musicdq][2])
While 1
Sleep(100)
WEnd
Func Button1Click()
If $musicdq - 1 > 0 Then
$musicdq -= 2
play($musicinfo[$musicdq][0], $musicinfo[$musicdq][1], $musicinfo[$musicdq][2])
EndIf
EndFunc ;==>Button1Click
Func Button2Click()
If $musicdq + 1 <= $musiczs Then play($musicinfo[$musicdq][0], $musicinfo[$musicdq][1], $musicinfo[$musicdq][2])
EndFunc ;==>Button2Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func play($name, $people, $path)
GUICtrlSetData($Label1, "歌曲名:" & $name & "---歌手:" & $people)
$musicdq += 1
If ProcessExists("wmplayer.exe") Then ProcessClose("wmplayer.exe")
Sleep(1000)
Run(@ProgramFilesDir & "\Windows Media Player\wmplayer.exe " & $path)
EndFunc ;==>play
Func _Source($url)
$source = _INetGetSource($url)
$sr = StringRegExp($source, ', "([^"]*)', 3)
Local $musicinfo[Int(UBound($sr) / 5)][3]
For $i = 0 To UBound($sr) - 1 Step 5
$musicinfo[Int($i / 5)][0] = $sr[$i]
$musicinfo[Int($i / 5)][1] = $sr[$i + 1]
$musicinfo[Int($i / 5)][2] = $sr[$i + 4]
$musiczs += 1
Next
Return $musicinfo
EndFunc ;==>_Source
|