I've added the option #PB_ListIcon_AlwaysShowSelection to the listIcon. You could remove it if you want.
I've added a second column to the list with a width of 0, so this column doesn't appear, and i lock the size of the first column (index 0). By this way, it's not possible to resize the first column with the mouse.
from my library MoreListIconGadget to do this.
I've created the procedure GetDroppedFiles() to get all files name dropped and i store the file name in the first column of the ListIcon and i store the Path into the second column and because its size = 0, it doesn't appear. Because if you store the Path name + the file name in the 1st column, it will be difficult to read quickly the name if it is long.
I've create the procedure LoadFileFromList() to load the name from the list, it's not complex and they are another ways to do that.
I've create (but it's not used in the code) the procedure GetMp3FileName() to get file names with an OpenFileRequester (you could select several files) and store the name as i done with the dropped ones.
So, when you get the file name, you have to play the file, but you must write the code.
Code: Select all
Global FontID1
FontID1 = LoadFont(1, "Comic Sans MS", 8)
Global FontID2
FontID2 = LoadFont(2, "Symbol", 10)
Global HintergrundFarbe1
Global HintergrundFarbe2
Declare GetMp3FileName() ; get filename
HintergrundFarbe1=CreateSolidBrush_(RGB(0,0,0)) ; schwarz
HintergrundFarbe2=CreateSolidbrush_(RGB(255,255,255))
Dim Progress.l(34)
Enumeration 0
#MP3_Unknown
#MP3_Stopped
#MP3_Playing
#MP3_Paused
EndEnumeration
#Window_0 = 0
;
Enumeration
#Gadget_Position
#Gadget_PositionTxt
#Gadget_PositionTxt1
#ProgressBar_0
#Gadget_Mute
#Gadget_Load
#Gadget_Play
#Gadget_Pause
#Gadget_Stop
#Frame3D_0
#Gadget_Volume
#Gadget_VolumeTxt
#Gadget_Speed
#Gadget_SpeedTxt
#Gadget_EC
#Playlist
#up
#random
#down
EndEnumeration
Global blauw
Global black
blauw=CreateSolidBrush_(RGB($67,$32,$98))
black=CreateSolidBrush_(RGB($00,$00,$00))
Procedure myCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_CTLCOLORSTATIC
Select lparam
Case GadgetID(#Gadget_Volume)
SetBkMode_(wParam,#TRANSPARENT)
SettextColor_(wParam, $FFFFFF)
Result = blauw
Case GadgetID(#Gadget_Mute)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = blauw
Case GadgetID(#Frame3D_0)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = black
Case GadgetID(#Gadget_VolumeTxt)
SetBkMode_(wParam,#TRANSPARENT)
SettextColor_(wParam, $FFFFFF)
Result = black
Case GadgetID(#Gadget_SpeedTxt)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = black
Case GadgetID(#Gadget_VolumeTxt)
SetBkMode_(wParam,#TRANSPARENT)
SettextColor_(wParam, $FFFFFF)
Result = black
Case GadgetID(#Gadget_Position)
SetBkMode_(wParam,#TRANSPARENT)
SettextColor_(wParam, $FFFFFF)
Result = blauw
Case GadgetID(#Gadget_Speed)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = blauw
Case GadgetID(#Gadget_EC)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = blauw
Case GadgetID(#Gadget_PositionTxt)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = black
Case GadgetID(#Gadget_PositionTxt1)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, $FFFFFF)
Result = black
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
hWnd = OpenWindow(#Window_0, 278, 107, 351, 261, #PB_Window_SystemMenu | #PB_Window_TitleBar , "Tiny MP3 Player[+]")
If hWnd
SetWinBackgroundColor(hWnd, RGB($67,$32,$98))
SetForeGroundWindow_(hWnd)
SetWindowCallback(@myCallback())
If CreateGadgetList(WindowID())
TrackBarGadget(#Gadget_Position, 20, 140, 310, 25, 0, 1000)
TextGadget(#Gadget_PositionTxt, 131,80,100,36,"")
TextGadget(#Gadget_PositionTxt1, 131,98,100,18,"")
ProgressBarGadget(#ProgressBar_0, 20, 170, 310, 15, 0, 1000, #PB_ProgressBar_Smooth)
SetProgressBarColor(#ProgressBar_0, #Black, RGB($67,$32,$98))
CheckBoxGadget(#Gadget_Mute, 30, 200, 70, 20, "Mute")
ButtonGadget(#Gadget_Load, 20, 10, 60, 40, "Load")
ButtonGadget(#Gadget_Play, 100, 10, 70, 40, "Play")
ButtonGadget(#Gadget_Pause, 180, 10, 70, 40, "Pause")
ButtonGadget(#Gadget_Stop, 270, 10, 60, 40, "Stop")
Frame3DGadget(#Frame3D_0, 20, 60, 310, 60, "MP3 Infomation", #PB_Frame3D_Single)
TrackBarGadget(#Gadget_Volume, 20, 230, 130, 20, 0, 100)
TextGadget(#Gadget_VolumeTxt, 21,82,100,18,"Volume")
TrackBarGadget(#Gadget_Speed, 130, 200, 200, 20, 90, 120)
TextGadget(#Gadget_SpeedTxt, 21,100,100,18,"Play Speed")
TrackBarGadget(#Gadget_EC, 250, 230, 80, 20, 0, 1, #PB_TrackBar_Ticks)
SetGadgetState(#Gadget_EC, 0)
LI= ListIconGadget(#Playlist, 10, 260, 330, 150,"Tracklist",255, #PB_ListIcon_AlwaysShowSelection)
SetColumnWidth(#Playlist, 0, #PB_Column_Autosize_FromHeader) ; first column width has the width of the
; listicongadget window
AddGadgetColumn(#Playlist, 1, "", 0) ; create a second column, not visible
; to store Path files names of Mp3 files
LockColumnSize(#Playlist, #PB_LockCol | 0) ; lock size of first column, it's now not possible
; to resize the first column with the mouse
SendMessage_(LI, #LVM_SETBKCOLOR,0,RGB($00,$00,$00))
SendMessage_(LI, #LVM_SETTEXTCOLOR,0,RGB($FF,$FF,$FF))
SendMessage_(LI, #LVM_SETTEXTBKCOLOR,0,RGB($00,$00,$00))
ButtonGadget(#up, 190, 230, 20, 20, "Ã