ich habe mir am Wochenende Gedanken zu meinem Programm gemacht.
von TS-Soft den Wrapper(ich glaube so wird das genannt?) für PureBasic.
Ich habe die Routine dokumentiert wo ich nicht weiter komme.
Denke mal das ich das Programm noch Optimieren kann auch wegen dem Event-Handling,
bin aber noch am lernen also Anfänger .
Ich bedanke mich jetzt schon mal bei Euch, das ihr mal ein Auge darauf geworfen hast.
Code: Alles auswählen
XIncludeFile "J:\Purebasic531\libzplay.pbi"
EnableExplicit
Enumeration
#Open_Win
#Ende
#Play
#Pause
#Stop
#Tree
#List
#Text_File
#Uhrzeit
#Status
#Total_Time
#Real_Time
#Edit_Gad
#Ausgabe
#Check_List
EndEnumeration
Global File.s
Global EventID
Global Result
Global i.i
Global hZPlay = zplay_CreateZPlay()
Global ID3.TID3InfoExW
Global TSI.TStreamInfo
Global TST.TStreamTime
Global THT.TStreamHMSTime
Global TSS.TStreamStatus
Global status = TSS\fplay
Global Time$
Global links.i,rechts.i,getbit.i
Global sectot,mintot,tottime,postime
Global sec,min,wahreposition,wp.f,Round
Global realtime,realsec,realmin
Global Playall.i,Max_Zeit.i,Ist_Zeit.i
OpenWindow(#Open_Win, 100,100, 1024, 768, "Testplayer Audio", #PB_Window_SystemMenu)
CanvasGadget(#Ausgabe,715,350,250,200)
ButtonGadget(#Ende,10,10,100,25,"Beenden")
ButtonGadget(#Play,110,10,100,25,"Play")
ButtonGadget(#Pause,210,10,100,25,"Pause")
ButtonGadget(#Stop,310,10,100,25,"Stop")
ExplorerTreeGadget(#Tree,10,40,700,300,"*.mp3",#PB_Explorer_NoFiles)
ExplorerListGadget(#List,10,350,700,300, "*.mp3",#PB_Explorer_NoFolders|#PB_Explorer_NoParentFolder|#PB_Explorer_MultiSelect|#PB_Explorer_List)
TextGadget(#Text_File,50,670,850,25,"")
CheckBoxGadget(#Check_List,715,40, 250, 20, "Play All in List")
If LoadFont(2, "Verdana",9) : EndIf
For i=3 To 1 Step -1
RemoveGadgetColumn(#List,i)
Next
SetGadgetItemAttribute(#List,0,#PB_Explorer_ColumnWidth,690)
AddWindowTimer(0, 1, 25)
Repeat
Time$ = FormatDate("%hh:%ii:%ss", Date())
zplay_GetVUData(hzplay,@links,@rechts)
zplay_GetPosition(hZPlay,@TST)
zplay_GetStreamInfo(hZPlay,@TSI)
zplay_GetStatus (hZplay,@TSS)
getbit= zplay_GetBitrate(hZPlay,1)
status = TSS\fplay
sectot=tottime%60:tottime/60
mintot=tottime%60:tottime/60
postime=TST\sec
sec=postime%60:postime/60
min=postime%60:postime/60
realtime= TSI\length.TStreamTime\sec
realsec = realtime%60:realtime/60
realmin = realtime%60:realtime/60
wahreposition = (min*60)+sec
wp.f=wahreposition*100 / TSI\length.TStreamTime\sec
round=Int(wp.f)
Max_Zeit = Int(realsec +(realmin*60)) ; gesamte Länge der Datei in Sekunden
Ist_Zeit = Int(sec + (min*60)) ; Abspiel Position der Datei in Sekunden
Repeat
EventID=WaitWindowEvent(1)
Select EventID
Case #PB_Event_Timer ; Zeige die Daten an.
If EventTimer() = 1
If StartDrawing(CanvasOutput(#Ausgabe))
Box(0,0,OutputWidth(),OutputHeight())
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(2))
FrontColor($000000)
DrawText(10,10,"Time "+Time$)
DrawText(10,25,"Status "+status) ; Die DLL gibt hier ihren Status zurück 1= Datei wird abgespielt 0= Abspielen beendet.
DrawText(10,40,"Gesamt Länge "+RSet(Str(realtime),2,"0")+":"+RSet(Str(realmin),2,"0")+":"+RSet(Str(realsec),2,"0"))
DrawText(10,55,"Position Titel "+RSet(Str(postime),2,"0")+":"+ RSet(Str(min),2,"0")+":"+ RSet(Str(sec),2,"0"))
DrawText(10,70,"Fortschritt "+StrF(wp.f,2)+ " % ") ; Fortschrittsanzeige in %
DrawText(10,85,"Play_All " +Playall) ; zeige mir ob CheckBox aktiviert ist. Hoffe das ist richtig?
DrawText(10,100,"Zur Zeit in Sek. " +Ist_Zeit) ;Int(sec + (min*60)))
DrawText(10,115,"Total in Sek. "+Max_Zeit) ;Int(realsec +(realmin*60)))
StopDrawing()
EndIf
EndIf
EndSelect
If EventID=#PB_Event_Gadget
Select EventGadget()
Case #Tree ;TreeGadget
If EventType() = #PB_EventType_LeftClick
; hier wähle ich ein Verzeichnis aus
SetGadgetText(#List,GetGadgetText(#Tree))
EndIf
Case #List ;Listgadget
If EventType() = #PB_EventType_LeftClick
; hier wähle ich per Maus Klick die Datei aus welche abgespielt werden soll
; das funktioniert auch sehr gut.
File = GetGadgetText(#List)+GetGadgetItemText(#List, GetGadgetState(#List))
If file <> ""
SetGadgetText(#Text_File," Datei = " +File)
zplay_OpenFile(hZPlay, File, #sfAutodetect)
zplay_Play(hZPlay)
EndIf
EndIf
Case #Pause
zplay_Pause(hZplay)
Case #Play
zplay_Play(hZPlay)
Case #Stop
zplay_Stop (hZplay)
zplay_Close(hzplay)
Case #Check_List
If GetGadgetState(#Check_List) = #PB_Checkbox_Checked
Playall = 1
Else
Playall = 0
EndIf
; ab hier komme ich nicht weiter, ??
If Playall=1 ; ist checkbox = 1 dann
zplay_Stop(hZPlay); erstmal alles stoppen
File=GetGadgetText(#List)+GetGadgetItemText(#List, GetGadgetState(#List)); hole mir den eintrag heraus (ExplorerListGadget)
If File <> "" ; ist File da dann
zplay_OpenFile(hZPlay,File,#sfAutodetect) ; öffne File
zplay_Play(hZPlay) ; spiele File ab
If Ist_Zeit=Max_Zeit ; Vergleich ob Ist_Zeit = Max_Zeit ist
If GetGadgetState(#List) > -1 And GetGadgetState(#List) < CountGadgetItems(#List)-1 ; jetzt hole ich mmir den nächsten Eintrag im Listgadget aber er springt den
; Eintrag nicht an ?? Oder muss ich den Status überprüfen ??
;
;
;
SetGadgetItemState(#List,GetGadgetState(#List)+1, #PB_Explorer_Selected )
File = GetGadgetItemText(#List,GetGadgetState(#List),0)
zplay_OpenFile(hZPlay,File,#sfAutodetect)
zplay_Play(hZPlay)
EndIf
EndIf
EndIf
EndIf
Case #Ende
Result = MessageRequester("Exit", "Close Program ?", #PB_MessageRequester_YesNo)
If Result = #PB_MessageRequester_Yes ; Ja-Schalter wurde gedrückt
End
EndIf
EndSelect
EndIf
If EventID = #PB_Event_CloseWindow
End
EndIf
Until EventID = 0
ForEver