IncludeFile "bass.pbi" Enumeration #Window_0 #But #Stil #Spisok #Track #Text EndEnumeration Global name.s Structure Spisok name.s ID.s EndStructure Global NewList MySpisok.Spisok() ; Динамически связанный список ;----вырезаем из строки между L и R Procedure.s Between_2(string.s, L.s, R.s) Position = FindString(string, L.s, 1) string2.s = Right(string, Len(string)+1-Position-Len(L.s)) Position2 = FindString(string2, R.s, 1) string3.s = Left(string2, Position2-1) If Position <> 0 ProcedureReturn string3.s EndIf EndProcedure ;----качаем список радиостанций по стилям Procedure Style() URLDownloadToFile_(0, "http://yp.shoutcast.com/sbin/newxml.phtml", "Temp.htm",0,0) If ReadFile(0, "Temp.htm") CreateFile(1, "Стили.txt") While Eof(0) = 0 string.s= ReadString(0) name.s= Between_2(string, "="+Chr(34), Chr(34)+">") If name.s <> "" WriteStringN(1, name.s) EndIf Wend CloseFile(1) CloseFile(0) DeleteFile("Temp.htm") EndIf EndProcedure LoadImage(0, "star.ico") LoadImage(1, "volume_loud.ico") LoadImage(2, "volume.ico") LoadImage(3, "star_loud.ico") ;----создаём список по стилям Procedure Spisok(put.s) If ReadFile(0, "Стили.txt") While Eof(0) = 0 string.s= ReadString(0) AddGadgetItem(#Stil, -1, string, ImageID(0)) Wend CloseFile(0) EndIf DeleteFile("Стили.txt") EndProcedure ;----список id и имён станций в зависимости от стиля Procedure ID(styl.s) ClearList(MySpisok()) ClearGadgetItems(#Spisok) url.s = "http://yp.shoutcast.com/sbin/newxml.phtml?genre="+styl.s URLDownloadToFile_(0, url, "Temp.htm",0,0) If ReadFile(0, "Temp.htm") While Eof(0) = 0 string.s= ReadString(0) name.s = Between_2(string, """ rezPot.s= potok.s ; получили адрес потока EndIf Wend CloseFile(3) DeleteFile("Temp.htm") EndIf ProcedureReturn rezPot.s EndProcedure OpenWindow (#Window_0, 0, 0,400, 800, "Радио- beta", #PB_Window_MinimizeGadget |#PB_Window_ScreenCentered|#PB_Window_SizeGadget) ButtonGadget(#But,10,5,80,20,"Вернуться") ListIconGadget(#Stil,5,30,390,760,"",350,#PB_ListIcon_DisplayMode|#PB_ListIcon_GridLines) ListIconGadget(#Spisok,-500,30,390,760,"",350,#PB_ListIcon_GridLines) Style() put.s=GetPathPart(ProgPath.s) Spisok(put.s) TrackBarGadget(#Track,95,5,220,20,0,100,#PB_TrackBar_Ticks) SetGadgetState(#Track, 50) TextGadget(#Text,320,5,100,20,"Стиль") BASS_Init(-1, 44100, 0, WindowID(#Window_0), #Null) ; инициализация BASS_ChannelSetAttribute( Handle,#BASS_ATTRIB_VOL,0.5) Vol.f=0.5 Item= -2 rez=-2 Repeat Event = WaitWindowEvent() Window = EventWindow() Gadget = EventGadget() Select Event Case #PB_Event_Gadget Select EventGadget() Case #Stil If EventType()= #PB_EventType_LeftDoubleClick ;-------------меняем иконку-------------------- rez1= rez styl1.s= styl.s RemoveGadgetItem(#Stil, rez) AddGadgetItem(#Stil, rez, styl.s,ImageID(0)) rez= GetGadgetState(#Stil) styl.s = GetGadgetItemText(#Stil, rez ) ;получили имя стиля ID(styl.s) ResizeGadget(#Stil,-500,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Spisok,5,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;-------------меняем иконку-------------------- If rez <> -1 RemoveGadgetItem(#Stil, rez) AddGadgetItem(#Stil, rez, styl.s , ImageID(3)) Else RemoveGadgetItem(#Stil, rez1) AddGadgetItem(#Stil, rez1, styl1.s , ImageID(3)) rez= rez1 styl.s= styl1.s EndIf ;--------------------------------------------- EndIf Klik=0 Case #But Klik = Klik ! 1 If Klik=1 ResizeGadget(#Stil,5,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Spisok,-500,#PB_Ignore,#PB_Ignore,#PB_Ignore) Else ResizeGadget(#Stil,-500,#PB_Ignore,#PB_Ignore,#PB_Ignore) ResizeGadget(#Spisok,5,#PB_Ignore,#PB_Ignore,#PB_Ignore) EndIf Item= -2 name.s= "" Case #Spisok If EventType()= #PB_EventType_LeftDoubleClick ;-------------меняем иконку-------------------- Item1= Item name1.s= name.s RemoveGadgetItem(#Spisok, Item) AddGadgetItem(#Spisok, Item, name.s,ImageID(2)) Item= GetGadgetState(#Spisok) name.s = GetGadgetItemText(#Spisok, Item ) ;получили имя станции ;--------------------------------------------- SetGadgetText(#Text, styl.s) SetWindowTitle(#Window_0, name.s) ForEach MySpisok() ; находим в списуе Id в зависимости от имени If MySpisok()\name.s=name.s id.s=MySpisok()\ID Break EndIf Next url.s= Potok(id.s) BASS_StreamFree(Handle) Handle=BASS_StreamCreateURL(url.s, 0, 0, #Null, 0) BASS_ChannelPlay(Handle,0) BASS_ChannelSetAttribute( Handle,#BASS_ATTRIB_VOL,Vol.f) ;-------------меняем иконку-------------------- If Item <> -1 RemoveGadgetItem(#Spisok, Item) AddGadgetItem(#Spisok, Item, name.s , ImageID(1)) Else RemoveGadgetItem(#Spisok, Item1) AddGadgetItem(#Spisok, Item1, name1.s , ImageID(1)) Item= Item1 name.s= name1.s EndIf ;--------------------------------------------- EndIf Case #Track Vol.f = GetGadgetState(#Track)/100 BASS_ChannelSetAttribute( Handle,#BASS_ATTRIB_VOL,Vol.f) EndSelect EndSelect If Event = #PB_Event_CloseWindow Break EndIf ForEver