La radio de Micoute
Publié : jeu. 12/déc./2013 15:10
Salut à tous, pour faire comme tout le monde, j'ai aussi fait ma radio, je me suis inspiré de tous vos codes et ça donne ça :
Si ça peut vous inspirer, ne vous gênez surtout pas !
Code : Tout sélectionner
EnableExplicit
IncludeFile "fmodex.pbi"
IncludeFile "MeterGadget.pbi"
Enumeration
#Mainform
EndEnumeration
Enumeration Gadget
#Option_0
#Option_1
#Option_2
#Option_3
#Option_4
#Option_5
#Option_6
#Option_7
#Option_8
#Option_9
#Option_10
#Option_11
#Option_12
#Option_13
#Option_14
#Option_15
#Conteneur
#Volume
#VU
#Txt_Titre
#txt_Volume
EndEnumeration
Enumeration Police
#Police
EndEnumeration
Define.l Event, GEvent, TiEvent
Global WindowStyle.i=#PB_Window_SystemMenu|#PB_Window_ScreenCentered
Global.i VuMeter, Police
Global fmodsystem.i, Channel.i, Sound.i
Global Dim Arr.F(512), N.i ; Tableau pour les 512 niveaux
Global Dim Station.s(15, 1)
Global Url.s
Global Dim VuMetre.MeterType(15)
Police = LoadFont(#Police, "Digit", 20, #PB_Font_Bold)
Procedure Reglages()
FMOD_System_Create(@fmodsystem)
FMOD_System_Init(fmodsystem, 32, 0, 0)
FMOD_System_CreateStream(fmodsystem, @Url, #FMOD_CREATESTREAM, 0, @sound)
FMOD_System_PlaySound(fmodsystem, 0, sound, 0, @channel) ; joue l'url
FMOD_Channel_SetVolume(Channel, GetGadgetState(#Volume)/250)
FMOD_Channel_GetSpectrum(channel, Arr(), 512, 0, 0 ) ; recuperere les 512 niveaux des frequences
EndProcedure
Procedure VUMeterUpdate()
Protected Sum.f
FMOD_Channel_GetSpectrum(channel, Arr(), 512, 0, 0 ) ; recuperere les 512 niveaux des frequences
FMOD_System_Update(Channel)
For N=0 To 512
Sum + Arr(N)
Next
SetMeterState(VuMeter, Sum*GetGadgetState(#Volume)/2)
EndProcedure
Procedure Stop()
FMOD_Channel_Stop(Channel)
FMOD_System_Release(fmodsystem)
EndProcedure
Procedure Open_MainForm()
OpenWindow(#Mainform, 0, 0, 500, 350, "La radio de Micoute", WindowStyle)
SetWindowColor(#Mainform, $300000)
VuMeter = MeterGadget(#PB_Any, 180, 70, 300, "VU")
TextGadget(#Txt_Titre, 180, 20, 300, 30, Station(8,0), #PB_Text_Center)
TrackBarGadget(#Volume, 180, 280, 300, 20, 0, 100)
TextGadget(#txt_Volume, 180, 310, 300, 25, "20", #PB_Text_Center)
ContainerGadget(#Conteneur, 10, 10, 150, 330, #PB_Container_Raised)
For i = 0 To 15
OptionGadget(i, 15, (i*19) + 10, 110, 19,Station(i, 0))
Next
SetGadgetColor(#Conteneur, #PB_Gadget_BackColor, $300000)
SetGadgetColor(#Txt_Titre, #PB_Gadget_BackColor, $300000)
SetGadgetColor(#Txt_Titre, #PB_Gadget_FrontColor, $00FFFF)
SetGadgetFont(#Txt_Titre, Police)
SetGadgetColor(#txt_Volume, #PB_Gadget_BackColor, $300000)
SetGadgetColor(#txt_Volume, #PB_Gadget_FrontColor, $00FFFF)
SetGadgetFont(#txt_Volume, Police)
AddWindowTimer(#Mainform, 100, 100)
SetGadgetState(#Option_7, 1)
SetGadgetState(#Volume, 20)
EndProcedure
Procedure Initialisation()
Restore Stations
For i = 0 To 15
Read.s, Station(i, 0)
Read.s, Station(i, 1)
Next
;Url ="http://50.7.98.106:8719"
Url = Station(8,1)
Open_MainForm()
EndProcedure
Initialisation()
Reglages()
Repeat
Event = WaitWindowEvent(100)
GEvent = EventGadget()
TiEvent = EventTimer()
Select Event
Case #PB_Event_Timer
Select TIEvent
Case 100
VUMeterUpdate()
EndSelect
Case #PB_Event_Gadget
Select GEvent
Case #Option_0 To #Option_15
Stop()
SetGadgetText(#Txt_Titre, UCase(Station(GEvent,0)))
Url = Station(GEvent,1)
Reglages()
VUMeterUpdate()
Case #Volume
Volume.f = GetGadgetState(#Volume) /250
FMOD_Channel_SetVolume(Channel, Volume)
SetGadgetText(#txt_Volume, Str(GetGadgetState(#Volume)))
EndSelect
Case #PB_Event_CloseWindow
Stop()
End
EndSelect
ForEver
DataSection
Stations:
Data.s "Brume", "http://live140.impek.com:9974/"
Data.s "Chante France","http://stream.chantefrance.com/stream_chante_france.mp3"
Data.s "Chérie FM", "http://mp3.live.tv-radio.com/cherrie_fm/all/che_124310.mp3"
Data.s "Chérie FM Frenchy","http://live.tv-radio.com/cherie_fm_frenchy/all/che_123008.mp3"
Data.s "Couleur 3","http://broadcast.infomaniak.ch/rsr-couleur-high.mp3"
Data.s "Demoiselle FM","http://213.186.61.62:8800/"
Data.s "France Culture","http://mp3.live.tv-radio.com/franceculture/all/franceculturehautdebit.mp3"
Data.s "France Info","http;//mp3.live.tv-radio.com/franceinfo/all/franceinfo.mp3"
Data.s "France Inter","http://mp3.live.tv-radio.com/franceinter/all/franceinterhautdebit.mp3"
Data.s "Le Mouv'","http://mp3.live.tv-radio.com/lemouv/all/lemouvhautdebit.mp3"
Data.s "Nostalgie","http://mp3.live.tv-radio.com/nostalgie/all/nos_113812.mp3"
Data.s "NRJ All French","http://mp3.live.tv-radio.com/nrj_friendly/all/nrj_164207.mp3"
Data.s "Oxyradio","http://www.oxyradio.net:8000/hd.ogg"
Data.s "Rires et chansons","http://95.81.147.3/rire_et_chansons/all/rir_124629.mp3"
Data.s "RTL2","http://streaming.radio.rtl2.fr/rtl2-1-44-128"
Data.s "RMC","http://vipicecast.yacast.net/rmc"
Data.s "999","999"
EndDataSection