Fond_Itunes = Image.load(MACXT_Path.."/Programs/ItunesV2/Images/Fond_Itunes.png")
dofile(MACXT_Path.."/Programs/ItunesV2/Itunes2.lua")
REGISTRY:Read("ItunesV2","ListeDeLecture")
Afficher_Preferences_Itunes2 = 0
Part_Itunes = 1
YPosSelecteurItunesMusic = 117
SelecteurItunesMusic = 1
MACXT_Programmes:NewAppli_MACXT()
while true do
   screen:blit(0,0,Fond_Itunes)
   MACXT_Objets_Barre[1] = {Caption = "Itunes",Fonction = "Options_Itunes"}
   MACXT_Objets_Barre[2] = {Caption = "Fichier",Fonction = "Options_Fichier"}
   MACXT_Objets_Barre[3] = {Caption = "Presentation",Fonction = "Options_Presentation"}
   MACXT_Repertoire:Actualise_Systeme_Barre()
   if Fonction_Barre == "Options_Itunes" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "A propos de Itunes",Action = "Propos_Itunes"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Preferences",Action = "Preferences_Itunes"}
      MACXT_Objets_Barre_Fonction[3] = {Caption = "Quitter Itunes",Action = "Exit_Itunes"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Fonction_Barre == "Options_Fichier" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "Ajouter a la biblio...",Action = "Add_Bibliotheque"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Ajouter le dossier",Action = "Add_Biblio_Dir"}
      MACXT_Objets_Barre_Fonction[3] = {Caption = "Lecture/Pause",Action = "Play/Pause"}
      MACXT_Objets_Barre_Fonction[4] = {Caption = "Stopper musique",Action = "Stop_Playing"}
      MACXT_Objets_Barre_Fonction[5] = {Caption = "Ouvrir musique",Action = "Open_Music"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Fonction_Barre == "Options_Presentation" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "Presentation coverflow",Action = "Coverflow_Presentation"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Presentation par liste",Action = "Liste_Presentation"}
      MACXT_Objets_Barre_Fonction[3] = {Caption = "Pres par classification",Action = "Classification_Presentation"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Action_Barre == "Play/Pause" then
      Mp3me.pause()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Stop_Playing" then
      Mp3me.stop()
      Player = 0
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Open_Music" then
      Finder_Module_Directory = "ms0:/"
      Extension = ".mp3"
      Module_Finder:Init_Finder_Module()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Preferences_Itunes" then
      Window_Hauteur = 110
      Window_Longueur = 270
      MACXT_Graphic:Init_New_Personnal_Window()
      Afficher_Preferences_Itunes2 = 1
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Propos_Itunes" then
      MACXT_Repertoire:Reinitialiser_Window()
      Window_Hauteur = 185
      Window_Longueur = 270
      MACXT_Title = "A propos de Itunes"
      MACXT_Graphic:Init_New_Personnal_Window()
      MACXT_Graphic:New_Textes()
      MACXT_Texte_Window[1] = {Caption = "Itunes est une application"}
      MACXT_Texte_Window[2] = {Caption = "permettant de lire des mp3"}
      MACXT_Texte_Window[3] = {Caption = "en incluant la possibilite de"}
      MACXT_Texte_Window[4] = {Caption = "de fonctionner avec une"}
      MACXT_Texte_Window[5] = {Caption = "bibliotheque. C'est la deuxieme"}
      MACXT_Texte_Window[6] = {Caption = "version de Itunes qui vous"}
      MACXT_Texte_Window[7] = {Caption = "est proposee"}
      MACXT_Repertoire:Actualise_Texte_Window()
      Affichage_Images = "Horizontal_Screen"
      MACXT_Images_Window[1] = {Images = Logo_Itunes_MACXT_Big}
      MACXT_Repertoire:Actualise_Images()
      MACXT_Repertoire:Anti_Bug()
   end
   if Player == 1 then
      if Titre_Music then
         screen:print(5,138,Titre_Music)
      end
      if Artiste_Music then
         screen:print(5,158,Artiste_Music)
      end
      if Album_Music then
         screen:print(5,178,Album_Music)
      end
      if Genre_Music then
         screen:print(5,198,Genre_Music)
      end
      if Annee_Music then
         screen:print(5,218,Annee_Music)
      end
      if Mp3me.eos() == 1 then
         Player = 0
         Mp3me.stop()
      end
      if MACXTKeyPad:start() then
         Mp3me.pause()
         screen.waitVblankStart(10)
      end
      if MACXTKeyPad:select() then
         Action_Barre = "Stop_Playing"
      end
      screen:print(480/2-string.len(Mp3me.gettime())*8/(2)-string.len(Mp3me.songTime())*8/(2),80,Mp3me.gettime().."/"..Mp3me.songTime())
      MACXT_Graphic:DrawRectangle(0,226,100,8,Color.new(0,0,0))
      screen:fillRect(0,226,Mp3me.percent(),8)
   end
   if Action_Barre == "Exit_Itunes" then
      Fond_Itunes = nil
	  Mp3me.stop()
	  Player = 0
      break
   end
   if Afficher_Preferences_Itunes2 == 1 then
      Itunes2:Options_Itunes2()
   end
   if Afficher_Options__ == 1 then
      Itunes2:Options__()
   end
   if AfficherTitres == 1 then
      screen:fillRect(184,YPosSelecteurItunesMusic,string.len(Itunes_Music_Files[SelecteurItunesMusic].Nom_Music_Itunes)*9,10,Color.new(0,0,255))
      Itunes2:Afficher_Bibliotheque()
      Itunes2:Use_Afficher_Bibliotheque()
   end
   --screen:print(5,50,"X = "..x.."Y = "..y)
   if x  >= 10 and x <= 25 and y >= 25 and y <= 40 then
      MACXTAide = "Fermer Itunes"
      if MACXTKeyPad:cross() then
         break
      end
   end
   MACXT_Kernel:Load_Kernel_Application()
screen.waitVblankStart()
screen:flip()
end
