Hey Leute ich hab mal meinen Music player und meinen Radiostream player zusammengepackt und es ein wenig "designt" wenn man das so nennen darf
Spoiler anzeigen
#include <Sound.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
OnAutoItExitRegister("_EXIT")
Dim $Sender[6]=[ "http://www.wdr.de/wdrlive/media/einslive.asx", _
"http://player.ffn.de/tunein_ffn.asx", _
"http://ndr-ndr1niedersachsen-hi-wma.wm.llnwd.net/ndr_ndr1niedersachsen_hi_wma", _
"mms://gffstream-wm-w24a.wm.llnwd.net/gffstream_wm_w24b", _
"http://gffstream.ic.llnwd.net/stream/gffstream_einslive_a", _
"http://listen.technobase.fm/tunein-dsl-pls" ]
$oWMP = ObjCreate ( "WMPLayer.ocx" )
$oWMP.URL = $Sender[0]
$oWMP.controls.stop()
$vol = 100
Dim $RadioItem[6]
Global $pfad = @UserProfileDir&"\Music\"
Global $titel = _FileListToArray($pfad,"*.mp3",1)
If IsArray($titel) = 0 Then
MsgBox(0,"ERROR","In dem ausgewählten Verzeichnis befinden sich keine .mp3 Dateien")
$pfad = FileSelectFolder("*MP3 Dateien angeben","C:")
$titel = _FileListToArray($pfad,"*.mp3",1)
EndIf
Global $titelnummer = 1
Global $sound
Global $volume = 100
Global $titelgui = "Music Player - " & $titel[$titelnummer]
Global $size = UBound($titel)
Global $var = 1
Global $balken
Global $shuffle = 1
Dim $groessetitel[$size]
Dim $listitem[$size]
Dim $string
Dim $length[5]
SoundSetWaveVolume($volume)
$Taschenrechner = GUICreate("Taschenrechner",500,530,-1,-1,$WS_POPUP)
GUISetBkColor(0x000000)
$verschiebungscontrol=GUICtrlCreateLabel("",220,0,220,40,"",$GUI_WS_EX_PARENTDRAG)
$bClose = GUICtrlCreateButton("X",470,10,20,20)
$bMinimize = GUICtrlCreateButton("_",440,10,20,20)
$bMusic = GUICtrlCreateButton("Musicplayer",10,10,100,20)
$bRadio = GUICtrlCreateButton("Radio",120,10,100,20)
$MusicB1 = GUICtrlCreateButton("<",10,40,50,50)
$MusicB2 = GUICtrlCreateButton(">",70,40,50,50)
$MusicB3 = GUICtrlCreateButton("+",130,40,50,50)
$MusicB4 = GUICtrlCreateButton("-",190,40,50,50)
$MusicB5 = GUICtrlCreateButton("| |",250,40,50,50)
$MusicB6 = GUICtrlCreateButton("Musik auswählen",310,40,110,50)
$MusicL1 = GUICtrlCreateLabel("Volume: "&$volume&"%",40,100)
$MusicL2 = GUICtrlCreateLabel("Titelanzahl: "&$size-1,150,100)
$MusicL3 = GUICtrlCreateLabel("Aktueller Titel: "&$titelnummer,260,100)
GUICtrlSetColor($MusicL1,0xFFFFAA)
GUICtrlSetColor($MusicL2,0xFFFFAA)
GUICtrlSetColor($MusicL3,0xFFFFAA)
$MusicP = GUICtrlCreateProgress(10,130,480,20)
$MusicList = GUICtrlCreateListView("Nr.|Titel |Größe|Länge",10,160,480,360)
$RadioStart = GUICtrlCreateButton("Start",10,40,100,50)
$RadioStop = GUICtrlCreateButton("Stop",120,40,100,50)
$RadioLauter = GUICtrlCreateButton("+",230,40,50,50)
$RadioLeiser = GUICtrlCreateButton("-",290,40,50,50)
$RadioList = GUICtrlCreateListView("Name|URL",10,100,480,420)
GUICtrlSetState($RadioLauter,$GUI_HIDE)
GUICtrlSetState($RadioLeiser,$GUI_HIDE)
GUICtrlSetState($RadioStart,$GUI_HIDE)
GUICtrlSetState($RadioStop,$GUI_HIDE)
GUICtrlSetState($RadioList,$GUI_HIDE)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Taschenrechner, "int", 200, "long", 0x00040010)
GUISetState()
getgroesse()
listefuellen()
play($titelnummer)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $bClose
Exit
Case $msg = $bMinimize
GUISetState(@SW_MINIMIZE)
Case $msg = $bRadio
GUICtrlSetState($MusicB1,$GUI_HIDE)
GUICtrlSetState($MusicB2,$GUI_HIDE)
GUICtrlSetState($MusicB3,$GUI_HIDE)
GUICtrlSetState($MusicB4,$GUI_HIDE)
GUICtrlSetState($MusicB5,$GUI_HIDE)
GUICtrlSetState($MusicB6,$GUI_HIDE)
GUICtrlSetState($MusicL1,$GUI_HIDE)
GUICtrlSetState($MusicL2,$GUI_HIDE)
GUICtrlSetState($MusicL3,$GUI_HIDE)
GUICtrlSetState($MusicP,$GUI_HIDE)
GUICtrlSetState($MusicList,$GUI_HIDE)
GUICtrlSetState($RadioLauter,$GUI_SHOW)
GUICtrlSetState($RadioLeiser,$GUI_SHOW)
GUICtrlSetState($RadioStart,$GUI_SHOW)
GUICtrlSetState($RadioStop,$GUI_SHOW)
GUICtrlSetState($RadioList,$GUI_SHOW)
$var = 1
playpause()
Case $msg = $bMusic
GUICtrlSetState($MusicB1,$GUI_SHOW)
GUICtrlSetState($MusicB2,$GUI_SHOW)
GUICtrlSetState($MusicB3,$GUI_SHOW)
GUICtrlSetState($MusicB4,$GUI_SHOW)
GUICtrlSetState($MusicB5,$GUI_SHOW)
GUICtrlSetState($MusicB6,$GUI_SHOW)
GUICtrlSetState($MusicL1,$GUI_SHOW)
GUICtrlSetState($MusicL2,$GUI_SHOW)
GUICtrlSetState($MusicL3,$GUI_SHOW)
GUICtrlSetState($MusicP,$GUI_SHOW)
GUICtrlSetState($MusicList,$GUI_SHOW)
GUICtrlSetState($RadioLauter,$GUI_HIDE)
GUICtrlSetState($RadioLeiser,$GUI_HIDE)
GUICtrlSetState($RadioStart,$GUI_HIDE)
GUICtrlSetState($RadioStop,$GUI_HIDE)
GUICtrlSetState($RadioList,$GUI_HIDE)
$oWMP.controls.stop()
Case $msg = $MusicB1
vorher()
Case $msg = $MusicB2
nachher()
Case $msg = $MusicB3
lauter()
Case $msg = $MusicB4
leiser()
Case $msg = $MusicB5
playpause()
Case $msg = $MusicB6
pfadaendern()
Case $msg = $RadioStart
$oWMP.controls.play()
Case $msg = $RadioStop
$oWMP.controls.stop()
Case $msg = $RadioLauter
If $vol < 100 then $vol += 10
$oWMP.settings.volume = $vol
Case $msg = $RadioLeiser
If $vol > 0 Then $vol -= 10
$oWMP.settings.volume = $vol
Case $msg = $RadioItem[0]
$oWMP.controls.stop()
$oWMP.URL = $Sender[0]
$oWMP.controls.play()
Case $msg = $RadioItem[1]
$oWMP.controls.stop()
$oWMP.URL = $Sender[1]
$oWMP.controls.play()
Case $msg = $RadioItem[2]
$oWMP.controls.stop()
$oWMP.URL = $Sender[2]
$oWMP.controls.play()
Case $msg = $RadioItem[3]
$oWMP.controls.stop()
$oWMP.URL = $Sender[3]
$oWMP.controls.play()
Case $msg = $RadioItem[4]
$oWMP.controls.stop()
$oWMP.URL = $Sender[4]
$oWMP.controls.play()
Case $msg = $RadioItem[5]
$oWMP.controls.stop()
$oWMP.URL = $Sender[5]
$oWMP.controls.play()
EndSelect
For $i=1 To $size-1
Switch $msg
Case $listitem[$i]
anderer($i)
EndSwitch
Next
titelende()
setbalken()
WEnd
Func play($nummer)
$sound = _SoundOpen($pfad&$titel[$nummer])
_SoundPlay($sound, 0)
EndFunc
Func vorher()
If $titelnummer >= 2 Then
_SoundClose($sound)
$titelvorher = $titelgui
$titelnummer = $titelnummer - 1
play($titelnummer)
$titelnachher = "Music Player - " & $titel[$titelnummer]
WinSetTitle($titelvorher,"",$titelnachher)
$titelgui = $titelnachher
GUICtrlSetData($MusicL3,"Aktueller Titel: "&$titelnummer)
Else
_SoundClose($sound)
$titelvorher = $titelgui
$titelnummer = $size-1
play($titelnummer)
$titelnachher = "Music Player - " & $titel[$titelnummer]
WinSetTitle($titelvorher,"",$titelnachher)
$titelgui = $titelnachher
GUICtrlSetData($MusicL3,"Aktueller Titel: "&$titelnummer)
EndIf
EndFunc
Func nachher()
If $titelnummer <= $size-2 Then
_SoundClose($sound)
$titelvorher = $titelgui
$titelnummer = $titelnummer + 1
play($titelnummer)
$titelnachher = "Music Player - " & $titel[$titelnummer]
WinSetTitle($titelvorher,"",$titelnachher)
$titelgui = $titelnachher
GUICtrlSetData($MusicL3,"Aktueller Titel: "&$titelnummer)
Else
_SoundClose($sound)
$titelvorher = $titelgui
$titelnummer = 1
play($titelnummer)
$titelnachher = "Music Player - " & $titel[$titelnummer]
WinSetTitle($titelvorher,"",$titelnachher)
$titelgui = $titelnachher
GUICtrlSetData($MusicL3,"Aktueller Titel: "&$titelnummer)
EndIf
EndFunc
Func lauter()
If $volume < 100 Then
$volume = $volume + 10
EndIf
SoundSetWaveVolume($volume)
GUICtrlSetData($MusicL1,"Volume: "&$volume&"%")
EndFunc
Func leiser()
If $volume > 0 Then
$volume = $volume - 10
EndIf
SoundSetWaveVolume($volume)
GUICtrlSetData($MusicL1,"Volume: "&$volume&"%")
EndFunc
Func playpause()
If $var = 1 Then
_SoundPause($sound)
GUICtrlSetData($MusicB5,"|>")
$var = $var*-1
Else
_SoundResume($sound)
GUICtrlSetData($MusicB5,"| |")
$var = $var*-1
EndIf
EndFunc
Func listefuellen()
For $i=1 To $size-1
$length1 = _SoundLength($pfad&$titel[$i])
$length2 = StringSplit($length1,":")
$length = $length2[2]&":"&$length2[3]
$listitem[$i] = GUICtrlCreateListViewItem($i&"|"&$titel[$i]&"|"&$groessetitel[$i]&"|"&$length,$MusicList)
Next
$RadioItem[0] = GUICtrlCreateListViewItem("EINSLIVE|"&$Sender[0],$RadioList)
$RadioItem[1] = GUICtrlCreateListViewItem("FFN|"&$Sender[1],$RadioList)
$RadioItem[2] = GUICtrlCreateListViewItem("NDR|"&$Sender[2],$RadioList)
$RadioItem[3] = GUICtrlCreateListViewItem("WDR2|"&$Sender[3],$RadioList)
$RadioItem[4] = GUICtrlCreateListViewItem("EINSLIVE DIGGI|"&$Sender[4],$RadioList)
$RadioItem[5] = GUICtrlCreateListViewItem("TECHNOBASE|"&$Sender[5],$RadioList)
EndFunc
Func getgroesse()
For $i=1 To $size-1
$groessetitel[$i] = FileGetSize($pfad&$titel[$i])/1000000
$groessetitel[$i] = Round($groessetitel[$i],2)
Next
EndFunc
Func anderer($anderer)
_SoundClose($sound)
$titelvorher = $titelgui
play($anderer)
$titelnachher = "Music Player - " & $titel[$anderer]
WinSetTitle($titelvorher,"",$titelnachher)
GUICtrlSetData($MusicL3,"Aktueller Titel: "&$anderer)
$titelgui = "Music Player - " & $titel[$anderer]
EndFunc
Func setbalken()
$length = _SoundLength($sound)
$pos = _SoundPos($sound)
$string1 = StringSplit($pos,":")
$string2 = StringSplit($length,":")
$lengthrichtig = $string2[2]*60+$string2[3]
$posrichtig = $string1[2]*60+$string1[3]
$balken = $posrichtig/$lengthrichtig*100
GUICtrlSetData($MusicP,$balken)
EndFunc
Func titelende()
If _SoundPos($sound) = _SoundLength($sound) Then
nachher()
EndIf
EndFunc
Func pfadaendern()
_SoundClose($sound)
_GUICtrlListView_DeleteAllItems($MusicList)
$pfadzwischen = FileSelectFolder("Musikordner auswählen","")
$pfad = $pfadzwischen&"\"
$titel = _FileListToArray($pfad,"*.mp3",1)
$size = UBound($titel)
listefuellen()
EndFunc
Func _EXIT()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Taschenrechner, "int", 200, "long", 0x00050010)
EndFunc
Vielleicht könnt ihr mir ja sagen was ich noch so verbesser kann, also designtechnisch und/oder neue Funktionen
Danke
DFPWare