ich versuche einen MP3-Player der anderen Art zu Coden, ist eigentlich mein erstes teil das ich Code. Nun habe ich gleich ein Problem. Irgendwie verträgt sich das PlayMP3() nicht mit dem Drag & Drop, egal was ich reindroppe er Spielt nix ab. Wenn ich aber der PlayMP3() eine Datei direkt zuweise z.b. PlayMP3("C:\123.mp3") dann geht es. Verzweifle schon ....
Code: Alles auswählen
Enumeration
#Window_0
EndEnumeration
Enumeration
#Gadget_0
EndEnumeration
Global Image0
Image0 = CatchImage(0, ?Image0)
DataSection
Image0:
IncludeBinary "snd.ico"
EndDataSection
Procedure.l DropFiles ()
ProcedureReturn EventwParam ()
EndProcedure
Procedure GetNumDropFiles (*dropFiles)
ProcedureReturn DragQueryFile_ (*dropFiles, $FFFFFFFF, temp$, 0)
EndProcedure
Procedure.s GetDropFile (*dropFiles, index)
bufferNeeded = DragQueryFile_ (*dropFiles, index, 0, 0)
For a = 1 To bufferNeeded: buffer$ + " ": Next
DragQueryFile_ (*dropFiles, index, buffer$, bufferNeeded+1)
ProcedureReturn buffer$
EndProcedure
Procedure FreeDropFiles (*dropFiles)
DragFinish_ (*dropFiles)
EndProcedure
Procedure PlayMP3(mp.s)
MCISendString_("CLOSE MP3",0,0,0)
Buffer$=Space(128)
MCISendString_("OPEN "+ mp +" TYPE MpegVideo ALIAS MP3",Buffer$,128,0)
MCISendString_("PLAY MP3",0,0,0)
EndProcedure
Procedure SetWinOpacity (hwnd.l, Opacity.l)
SetWindowLong_(hwnd, #GWL_EXSTYLE, $00080000)
If OpenLibrary(1, "user32.dll")
CallFunction(1, "SetLayeredWindowAttributes", hwnd, 0, Opacity, 2)
CloseLibrary(1)
EndIf
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 310, 153, 48, 48, #PB_Window_BorderLess| #PB_Window_ScreenCentered , "")
If CreateGadgetList(WindowID())
ImageGadget(#Gadget_0, 0, 0, 48, 48, Image0)
SetWinOpacity(WindowID(), 100)
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
DragAcceptFiles_ (WindowID(), 1)
Select WaitWindowEvent ()
Case #WM_DROPFILES
*dropped = DropFiles ()
num.l = DragQueryFile_ (*dropped , $FFFFFFFF, temp$, 0)
f$ = ""
For files = 0 To num - 1
f$ + GetDropFile (*dropped, files) + Chr (13)
Next
PlayMP3(f$)
FreeDropFiles (*dropped)
EndSelect
ForEver
MFG Lukaso
Edit by NicTheQuick: Quote-Tags durch Code-Tags ersetzt