Accueil > > > ERYSTREAMING V2.05 CS4 AS3
ERYSTREAMING V2.05 CS4 AS3
Information sur la source
Description
VRSION 2.05 Tous les problèmes ont été résolus. C'est donc la version finale. De plus, cette application peut tourner sur le réseau. A l'adresse ci-dessous, vous trouverez une page où il est possible de télécharger la projection Windows. Pour ce qui est du mode AAC, les stations Shoutcast ne sont pas encore accessibles, il faut donc attendre qu'ils sortent un lecteur adapté à ce streaming, mais en attendant, vous pouvez utiliser Vlc avec le fichier pls. VERSION 2.03 Une nouvelle version est disponible. Maintenant, il est possible d'utiliser les streaming shoutcast. Pour comprendre le fonctionnement, j'ai francophonisé le lecteur "embed" de leur site, et j'ai légèrement modifié tout ce qui ne me plaisait pas, c'est-à-dire presque tout. Là, c'est du POO, mais j'avoue que je n'ai pas absolument tout pigé, surtout la classe texte défilant. La source est présente dans le zip. La version 2.03 dispose d'un petit bouton rond de couleur verte, qui donne accès à la configuration du lecteur, ainsi qu'à la saisie d'adresse de streaming. Le bouton "Cache" active ou désactive la limitation du fichier temporaire situé dans le cache. Le bouton "Proxy" active ou désactive le mode de passage par le proxy pour pouvoir accéder aux fichiers pls, sinon une erreur sécurité du sandbox Adobe est déclarée. Les boutons "Liste 1" et "liste 2" permettent de changer de liste.Il reste un petit problème sur certaines adresses de flux au format suivant (Ex:http://xxx.xxx.xxx.xxx:xxxx). En effet, le sandbox fait encore des siennes. Je vais intégrer un proxy de streaming dans la version finale. Sinon, vous pouvez compiler en mode exécutable, et mettre sous la même racine, le proxy, et les fichiers xml. Le lecteur ne fonctionnera plus sur ce site. Avec la fonction de saisie d'adresse (A valider par la touche Enter), vous pouvez tester pratiquement toutes les adresses de flux existantes. Il reste un autre problème quant au streaming AAC. Il est visible à l'adresse suivante : http://www.erysoft.fr/test/erystreaming/index.html Voici la balise objet pour placer ce lecteur en ligne : <object width="516" height="150" data="./erystreaming_V2.03.swf?vol=80&lis1=./s tation_1.xml&lis2=./station_2.xml&pro=./streax y.php" type="application/x-shockwave-flash"> <param name="src" value="./erystreaming_V2.03.swf?vol=80&lis1=./ station_1.xml&lis2=./station_2.xml&pro=./strea xy.php" /> </object> Il faut IMPERATIVEMENT que tous les fichiers soient sur le même domaine, sinon le sandbox (Bac à sable !) va déclarer une erreur. Les fichiers images, xml, et média ne posent pas de problèmes. ANCIENNE VERSION V2.00 Voici la source d'un lecteur radio streaming utilisant le mode mp3, et le mode aac (Flux Rtmp). J'ai vu qu'il existait déjà une source à ce sujet, et je n'ai pas compris pourquoi le mec en question l'avait verrouillé, puisqu'il existe le MEME zip beaucoup plus complet sur internet. Enfin bref ! Le lecteur se lance automatiquement après le chargement. Une liste de radios /broadcast.infomaniak/ est pré-enregistrée. Vous pouvez sélectionner la radio avec les deux flèches vertes, stopper et relancer le streaming. Quand le nom de la station est encadré par un bouton, il suffit de faire un clic dessus pour changer de station. La station en cours d'écoute ne l'aura pas. De plus, vous pouvez changer le mode de streaming en faisant un clic sur le texte du flux en cours (Ex : AAC-H). Suivant la disponibilité, vous avez le choix entre 1 à 4 flux. J'ai fait un effort de présentation du lecteur, mais vous pouvez le modifier à volonté. Le code est assez complexe, et il m'est impossible d'expliquer le pourquoi de chaque ligne. Donc, c'est une source réservée aux initiés.
Source
- package
- {
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.events.*;
- import flash.net.URLLoader;
- import flash.net.URLRequest;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- import flash.utils.Timer;
- import flash.media.Sound;
- import flash.media.SoundLoaderContext;
- import flash.media.SoundTransform;
- import flash.media.SoundChannel;
- import flash.ui.Keyboard;
-
- public class erystreaming extends MovieClip
- {
- const INFOMANIAK :String = new String("http://<station>.ice.infomaniak.ch.ice.infomaniak.ch/meta.xsl?mount=/<station>-high.mp3");
- const STATSLIVE :String = new String("http://statslive.infomaniak.ch/player/xml/");
- const BROADCAST :String = new String("http://broadcast.infomaniak.ch/player/");
- const VERIFAAC :String = new String("http://statslive.infomaniak.ch/player/xml/verifAAC.php?fic=");
- const SHOUTCAST :String = new String("http://yp.shoutcast.com/sbin/tunein-station.pls?id=");
- const PHP_SHOUTCAST :String = new String("http://yp.shoutcast.com/Metadata_Info1.php");
- const PROXY_STREAMING :String = new String("http://www.erysoft.fr/test/erystreaming/streaxy.php");
- const LISTE_INFOMANIAK :String = new String("http://www.erysoft.fr/test/erystreaming/station_1.xml");
- const LISTE_SHOUTCAST :String = new String("http://www.erysoft.fr/test/erystreaming/station_2.xml");
- const ESPACE :String = new String(" ");
- const MODE_INFOMANIAK :int = 1;
- const MODE_URL :int = 2;
- const MODE_SHOUTCAST :int = 3;
- const FENETRE_SAISIE :fenetre_saisie_flux = new fenetre_saisie_flux;
-
- var liste_station :Array;
-
- var parametre :Object = loaderInfo.parameters;
-
- var parametre_station :String = parametre.sta;
- var parametre_volume :String = parametre.vol;
- var parametre_nom :String = parametre.nom;
- var parametre_auto :String = parametre.aut;
- var parametre_proxy :String = parametre.pro;
- var parametre_liste_1 :String = parametre.lis1;
- var parametre_liste_2 :String = parametre.lis2;
-
- var timer_flux :Timer;
- var timer_affichage :Timer;
- var son_flux :Sound;
- var canal_flux :SoundChannel;
- var effet_flux :SoundTransform;
- var connexion_reseau :NetConnection;
- var flux_audio :NetStream;
-
- var flux_mp3_haut :String;
- var flux_mp3_bas :String;
- var nom_station :String;
- var serveur_rtmp :String;
- var repertoire_rtmp :String;
- var flux_rtmp_haut :String;
- var flux_rtmp_bas :String;
- var test_rtmp_haut :String;
- var test_rtmp_bas :String;
- var domaine_station :String;
- var flux_courant :String;
- var titre_musique :String;
- var artiste_musique :String;
- var status_connexion :String = "ERYSTREAMING V2.05";
- var racine_rtmp :String;
- var texte_defilant :String;
- var station_texte :String;
- var memoire_texte :String;
-
- var volume_streaming :Number;
-
- var pointeur_station :int = 0;
- var pointeur_flux :int = 0;
- var mode_streaming :int = 0;
- var compteur_barre :int = 0;
- var rotation_affichage :int = 0;
- var numero_liste :int = 0;
- var compteur_defilement :int = 0;
-
- var debug_xml :Boolean = false;
- var test_acc_haut_bas :Boolean;
- var etat_aac :Boolean = false;
- var etat_marche :Boolean = false;
- var modification_volume :Boolean = false;
- var etat_proxy :Boolean = true;
- var une_fois :Boolean = false;
- var etat_cache :Boolean = true;
- var etat_meta :Boolean = false;
- var operation_en_cours :Boolean = false;
-
- public function erystreaming():void
- {
- if (parametre_proxy == null) parametre_proxy = PROXY_STREAMING;
- if (parametre_liste_1 == null) parametre_liste_1 = LISTE_INFOMANIAK;
- if (parametre_liste_2 == null) parametre_liste_2 = LISTE_SHOUTCAST;
- chargement_liste_xml(parametre_liste_1);
- numero_liste = 1;
- if (parametre_volume == null) volume_streaming = 0.75;
- else volume_streaming = int(parametre_volume) / 100
- lecteur.bouton_volume.x = 23 + 82 * volume_streaming;
- this.lecteur.bouton_play.addEventListener(MouseEvent.CLICK, action_bouton_play);
- this.lecteur.bouton_stop.addEventListener(MouseEvent.CLICK, action_bouton_stop);
- this.lecteur.bouton_station_plus.addEventListener(MouseEvent.CLICK, action_bouton_station_plus);
- this.lecteur.bouton_station_moins.addEventListener(MouseEvent.CLICK, action_bouton_station_moins);
- this.lecteur.bouton_saisie_flux.addEventListener(MouseEvent.CLICK, action_bouton_saisie_flux);
- this.lecteur.bouton_flux.addEventListener(MouseEvent.CLICK, action_bouton_flux);
- this.lecteur.bouton_selection_station.addEventListener(MouseEvent.CLICK, action_bouton_selection_station);
- this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_DOWN, action_bouton_volume_down);
- this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_OUT, action_bouton_volume_up);
- this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_UP, action_bouton_volume_up);
- this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_MOVE, action_bouton_volume_move);
- lecteur.bouton_volume.buttonMode = true;
- lecteur.bouton_selection_station.visible = false;
- lecteur.bouton_flux.visible = false;
- eteindre_voyant_controle();
- initialisation_bargraph();
- timer_affichage = new Timer(10);
- timer_affichage.addEventListener(TimerEvent.TIMER, action_timer_affichage);
- timer_affichage.start();
- timer_flux = new Timer(10);
- timer_flux.addEventListener(TimerEvent.TIMER, action_timer_flux);
- if (!etat_proxy) lecteur.voyant_proxy.visible = false;
- else lecteur.voyant_proxy.visible = true;
- if (parametre_auto) action_bouton_play(null);
- }
- private function lecture_information_station():void
- {
- eteindre_voyant_controle();
- if (!etat_proxy) lecteur.voyant_proxy.visible = false;
- else lecteur.voyant_proxy.visible = true;
- status_connexion = "CONNEXION EN COURS";
- if (parametre_station.indexOf("|") != -1)
- {
- mode_streaming = MODE_SHOUTCAST;
- lecteur.bouton_flux.visible = false;
- var tableau:Array = parametre_station.split("|");
- etat_aac = false;
- if (tableau[2] == "AAC") etat_aac = true;
- if (etat_proxy) chargement_fichier_pls_proxy(parametre_proxy, tableau[0]);
- else chargement_fichier_pls(SHOUTCAST + tableau[0]);
- }
- else if (parametre_station.indexOf("http://") != -1)
- {
- mode_streaming = MODE_URL;
- flux_courant = parametre_station;
- ouverture_flux_mp3();
- station_texte = parametre_station;
- }
- else
- {
- mode_streaming = MODE_INFOMANIAK;
- lecteur.bouton_flux.visible = true;
- var adresse:String;
- if (debug_xml) adresse = STATSLIVE;
- else adresse = BROADCAST;
- adresse += "configuration_" + parametre_station + ".xml?time=" + new Date().getTime();
- trace("- Xml : " + adresse);
- chargement_fichier_xml(adresse);
- }
- }
- private function chargement_liste_xml(url_liste:String):void
- {
- var chargeur_xml:URLLoader = new URLLoader(new URLRequest(url_liste));
- chargeur_xml.addEventListener(Event.COMPLETE, fin_chargement_liste_xml);
- chargeur_xml.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_xml.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_pls(url_pls:String):void
- {
- var chargeur_pls:URLLoader = new URLLoader(new URLRequest(url_pls + "&file=filename.pls"));
- chargeur_pls.addEventListener(Event.COMPLETE, fin_chargement_pls);
- chargeur_pls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_pls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_pls_proxy(url_proxy:String, parametre:String):void
- {
- parametre += "&time=" + new Date().getTime();
- var chargeur_pls:URLLoader = new URLLoader(new URLRequest(url_proxy + "?hdr=0&opt=pls&par=" + parametre));
- chargeur_pls.addEventListener(Event.COMPLETE, fin_chargement_pls);
- chargeur_pls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_pls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_meta(url_meta:String):void
- {
- var chargeur_meta:URLLoader = new URLLoader(new URLRequest(url_meta + "?surl=" + flux_courant));
- chargeur_meta.addEventListener(Event.COMPLETE, fin_chargement_meta);
- chargeur_meta.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_meta.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_meta_proxy(url_proxy:String):void
- {
- var parametre:String = flux_courant.substring(7, flux_courant.length) + "&time=" + new Date().getTime();
- var chargeur_meta:URLLoader = new URLLoader(new URLRequest(url_proxy + "?hdr=0&opt=meta&par=" + parametre));
- chargeur_meta.addEventListener(Event.COMPLETE, fin_chargement_meta);
- chargeur_meta.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_meta.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_xls(url_xls:String):void
- {
- var parametre:String = "&time=" + new Date().getTime();
- var chargeur_xls:URLLoader = new URLLoader(new URLRequest(url_xls.replace(/<station>/gi, domaine_station) + parametre));
- chargeur_xls.addEventListener(Event.COMPLETE, fin_chargement_fichier_xls);
- chargeur_xls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_xls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_fichier_xml(url_xml:String):void
- {
- var chargeur_xml:URLLoader = new URLLoader(new URLRequest(url_xml));
- chargeur_xml.addEventListener(Event.COMPLETE, fin_chargement_fichier_xml);
- chargeur_xml.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_xml.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function chargement_rtmp_information(url_rtmp_info:String):void
- {
- var chargeur_rtmp:URLLoader = new URLLoader(new URLRequest(url_rtmp_info));
- chargeur_rtmp.addEventListener(Event.COMPLETE, fin_chargement_rtmp);
- chargeur_rtmp.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- chargeur_rtmp.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- }
- private function preparation_lecteur():void
- {
- station_texte = controle_texte_affichage(nom_station);
- if (flux_mp3_haut != null) flux_mp3_haut = "http://" + domaine_station + ".ice.infomaniak.ch" + flux_mp3_haut;
- if (flux_mp3_bas != null) flux_mp3_bas = "http://" + domaine_station + ".ice.infomaniak.ch" + flux_mp3_bas;
- if (flux_rtmp_haut != null) test_rtmp_haut = VERIFAAC + flux_rtmp_haut;
- if (flux_rtmp_bas != null) test_rtmp_bas = VERIFAAC + flux_rtmp_bas;
- racine_rtmp = serveur_rtmp + "/" + repertoire_rtmp;
- trace("- Flux mp3 haut : " + flux_mp3_haut);
- trace("- Flux mp3 bas : " + flux_mp3_bas);
- trace("- Flux Rtmp haut : " + flux_rtmp_haut);
- trace("- Flux Rtmp bas : " + flux_rtmp_bas);
- trace("- Test Rtmp haut : " + test_rtmp_haut);
- trace("- Test Rtmp bas : " + test_rtmp_bas);
- trace("- Racine Rtmp : " + racine_rtmp);
- test_acc_haut_bas = true;
- if (test_rtmp_haut != null) chargement_rtmp_information(test_rtmp_haut);
- else lancer_lecteur(null, null);
- }
- private function lancer_lecteur(comment:String, debit:String):void
- {
- if (etat_marche) return;
- initialisation_bargraph();
- eteindre_voyant_controle();
- etat_aac = false;
- operation_en_cours = true;
- if (comment == null)
- {
- if (flux_rtmp_haut != null)
- {
- flux_courant = flux_rtmp_haut;
- initialisation_connexion(racine_rtmp);
- lecteur.texte_flux.text = "AAC-H";
- pointeur_flux = 2;
- }
- else
- {
- flux_courant = flux_mp3_haut;
- ouverture_flux_mp3();
- lecteur.texte_flux.text = "MP3-H";
- pointeur_flux = 0;
- }
- }
- else if (comment == "IDEM")
- {
- if (flux_courant.toLowerCase().indexOf(".aac",0) != -1) initialisation_connexion(racine_rtmp);
- else ouverture_flux_mp3();
- }
- else if (comment == "AAC")
- {
- if (debit == "H")
- {
- flux_courant = flux_rtmp_haut;
- lecteur.texte_flux.text = "AAC-H";
- }
- else
- {
- flux_courant = flux_rtmp_bas;
- lecteur.texte_flux.text = "AAC-L";
- }
- if (flux_courant != null) initialisation_connexion(racine_rtmp);
- else lecteur.texte_flux.text = "---";
- }
- else if (comment == "MP3")
- {
- if (debit == "H")
- {
- flux_courant = flux_mp3_haut;
- lecteur.texte_flux.text = "MP3-H";
- }
- else
- {
- flux_courant = flux_mp3_bas;
- lecteur.texte_flux.text = "MP3-L";
- }
- if (flux_courant != null) ouverture_flux_mp3();
- else lecteur.texte_flux.text = "---";
- }
- else lecteur.texte_flux.text = "---";
- }
- private function arret_lecteur():void
- {
- initialisation_bargraph();
- etat_marche = false;
- etat_meta = false;
- operation_en_cours = false;
- if (etat_aac)
- {
- try {flux_audio.close();}
- catch(e:Error) {}
- }
- else
- {
- try
- {
- son_flux.close();
- canal_flux.stop();
- }
- catch(e:Error) {}
- }
- try {timer_flux.stop();}
- catch(e:Error) {}
- status_connexion = "DECONNECTE";
- }
- private function ouverture_flux_mp3():void
- {
- if ( flux_courant.toLowerCase().indexOf(".mp3", 0) == - 1) son_flux = new Sound(new URLRequest(flux_courant + "/;pipi_caca_popo.mp3"));
- else son_flux = new Sound(new URLRequest(flux_courant));
- canal_flux = new SoundChannel();
- effet_flux = new SoundTransform();
- son_flux.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- son_flux.addEventListener(ProgressEvent.PROGRESS, gestion_progression_chargement);
- canal_flux = son_flux.play();
- effet_flux.volume = volume_streaming;
- effet_flux.pan = 0;
- canal_flux.soundTransform = effet_flux;
- }
- private function initialisation_connexion(url_net:String):void
- {
- etat_aac = true;
- connexion_reseau = new NetConnection();
- connexion_reseau.addEventListener(NetStatusEvent.NET_STATUS, gestion_status_reseau);
- connexion_reseau.addEventListener(AsyncErrorEvent.ASYNC_ERROR, erreur_asynchrone_reseau);
- connexion_reseau.connect(url_net);
- }
- private function ouverture_flux_aac():void
- {
- effet_flux = new SoundTransform();
- flux_audio = new NetStream(connexion_reseau);
- flux_audio.addEventListener(NetStatusEvent.NET_STATUS, gestion_status_reseau);
- flux_audio.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
- flux_audio.addEventListener(AsyncErrorEvent.ASYNC_ERROR, erreur_asynchrone_reseau);
- flux_audio.bufferTime = Number(5);
- flux_audio.play(flux_courant);
- effet_flux.volume = volume_streaming;
- flux_audio.soundTransform = effet_flux;
- }
- private function gestion_volume():void
- {
- volume_streaming = (lecteur.bouton_volume.x - 23) / 82
- effet_flux = new SoundTransform();
- effet_flux.volume = volume_streaming;
- effet_flux.pan = 0;
- if (etat_aac) flux_audio.soundTransform = effet_flux;
- else canal_flux.soundTransform = effet_flux;
- }
- private function gestion_bargraph(numero:int, valeur:int):void
- {
- var objet:Object = new Object();
- switch (numero)
- {
- case 0 : objet = lecteur.bargraph.barre_0; break;
- case 1 : objet = lecteur.bargraph.barre_1; break;
- case 2 : objet = lecteur.bargraph.barre_2; break;
- case 3 : objet = lecteur.bargraph.barre_3; break;
- case 4 : objet = lecteur.bargraph.barre_4; break;
- case 5 : objet = lecteur.bargraph.barre_5; break;
- case 6 : objet = lecteur.bargraph.barre_6; break;
- case 7 : objet = lecteur.bargraph.barre_7; break;
- case 8 : objet = lecteur.bargraph.barre_8; break;
- case 9 : objet = lecteur.bargraph.barre_9;
- }
- if (valeur >= 0) objet.height = valeur;
- else if (etat_aac) objet.height = int(20 * Math.random()) + 10;
- else
- {
- if (numero < 6) objet.height = int(40 * canal_flux.leftPeak);
- else objet.height = int(40 * canal_flux.rightPeak);
- }
- objet.y = 40 - objet.height;
- }
- private function initialisation_bargraph():void
- {
- for (var i:int = 0; i < 10; i++) gestion_bargraph(i, 1);
- }
- private function gestion_affichage_station():void
- {
- if (liste_station[pointeur_station] != parametre_station) lecteur.bouton_selection_station.visible = true;
- else lecteur.bouton_selection_station.visible = false;
- if (liste_station[pointeur_station].indexOf("|") != - 1)
- {
- var table:Array = liste_station[pointeur_station].split("|");
- station_texte = controle_texte_affichage(table[1]);
- }
- else station_texte = controle_texte_affichage(liste_station[pointeur_station]);
- }
- private function initialisation_variable():void
- {
- flux_mp3_haut = null;
- flux_mp3_bas = null;
- nom_station = null;
- serveur_rtmp = null;
- repertoire_rtmp = null;
- flux_rtmp_haut = null;
- flux_rtmp_bas = null;
- test_rtmp_haut = null;
- test_rtmp_bas = null;
- domaine_station = null;
- flux_courant = null;
- racine_rtmp = null;
- }
- private function eteindre_voyant_controle():void
- {
- lecteur.voyant_erreur_securite.visible = false;
- lecteur.voyant_erreur_chargement.visible = false;
- }
- private function controle_texte_affichage(texte:String):String
- {
- var reponse:String = new String("");
- texte = texte.replace("à","a").replace("é","e").replace("è","e").replace("ë","e").replace("ê","e").replace("ù","u").replace("ç","c").replace("ô","o");
- for (var i:int = 0; i < texte.length; i++)
- {
- if (texte.charCodeAt(i) >= 0x20 && texte.charCodeAt(i) < 0x7F) reponse += texte.charAt(i);
- }
- return reponse;
- }
- private function recuperation_meta_donnee():void
- {
- switch (mode_streaming)
- {
- case MODE_SHOUTCAST :
- if (etat_proxy) chargement_fichier_meta_proxy(parametre_proxy);
- else chargement_fichier_meta(PHP_SHOUTCAST);
- break;
- case MODE_URL :
- break;
- case MODE_INFOMANIAK :
- chargement_fichier_xls(INFOMANIAK);
- }
- }
- private function defilement_texte(texte:String):String
- {
- if (texte == null) return "";
- if (!etat_marche || lecteur.bouton_selection_station.visible) return texte;
- compteur_defilement++;
- if (compteur_defilement > 20) compteur_defilement = 0;
- if (texte != memoire_texte)
- {
- texte_defilant = texte;
- memoire_texte = texte;
- }
- if (compteur_defilement == 0)
- {
- if (texte_defilant.length > 0) texte_defilant = texte_defilant.substr(1, texte_defilant.length);
- else texte_defilant = ESPACE + texte;
- }
- return texte_defilant;
- }
- // Evènements -------------------------------------------------------------------------------------------------------------
- private function fin_chargement_liste_xml(e:Event):void
- {
- liste_station = new Array();
- var texte:XML = new XML(e.target.data);
- texte.ignoreWhitespace;
- var lignes:XMLList = texte.elements();
- for each (var ligne:XML in lignes) liste_station.push(ligne.@nom.toString());
- pointeur_station = 0;
- gestion_affichage_station();
- }
- private function fin_chargement_fichier_xml(e:Event):void
- {
- initialisation_variable();
- var texte:XML = new XML(e.target.data);
- texte.ignoreWhitespace;
- var lignes:XMLList = texte.elements();
- for each (var ligne:XML in lignes)
- {
- switch (ligne.@name.toString())
- {
- case "sFeedHigh" : flux_mp3_haut = ligne.@value; break;
- case "sFeedLow" : flux_mp3_bas = ligne.@value; break;
- case "sNomRadio" : nom_station = ligne.@value; break;
- case "sRtmpServer" : serveur_rtmp = ligne.@value; break;
- case "sRtmpDir" : repertoire_rtmp = ligne.@value; break;
- case "sRtmpFeedHigh" : flux_rtmp_haut = ligne.@value; break;
- case "sRtmpFeedLow" : flux_rtmp_bas = ligne.@value; break;
- case "sDomain" : domaine_station = ligne.@value; break;
- default : trace("< Paramètre inconnu ou ignoré >");
- }
- trace("- " + ligne.@name + " : " + ligne.@value);
- if (domaine_station == null) domaine_station = flux_mp3_haut.substr(0, flux_mp3_haut.indexOf("-",0));
- }
- preparation_lecteur();
- }
- private function fin_chargement_rtmp(e:Event):void
- {
- var texte:String = new String(e.target.data);
- if (test_acc_haut_bas)
- {
- if (texte == "done2=1")
- {
- trace("- Rtmp High actif");
- test_acc_haut_bas = false;
- if (test_rtmp_bas != null)
- {
- chargement_rtmp_information(test_rtmp_bas);
- return;
- }
- }
- else
- {
- trace("- Rtmp High inactif");
- flux_rtmp_haut = null;
- }
- }
- else
- {
- if (texte == "done2=1") trace("- Rtmp Low actif");
- else
- {
- trace("- Rtmp Low inactif");
- flux_rtmp_bas = null;
- }
- }
- lancer_lecteur(null, null);
- }
- private function fin_chargement_pls(e:Event):void
- {
- var adresse_streaming:String = null;
- var texte_streaming:String = null;
- var ligne_occupee:String = null;
- var ligne_disponible:String = null;
- var ligne:Array = new Array();
- var serveur_invalide:Boolean = false;
- var serveur_sature:Boolean = false;
- flux_courant = null;
- nom_station = null;
- trace("- Fichier pls chargé : \n" + e.currentTarget.data);
- ligne = e.currentTarget.data.split("\n");
- if (ligne[0] == "[playlist]")
- {
- adresse_streaming = ligne[2].toString();
- flux_courant = adresse_streaming.substring((adresse_streaming.indexOf("=") + 1), adresse_streaming.length);
- texte_streaming = ligne[3].toString();
- nom_station = texte_streaming.substring((texte_streaming.indexOf(")") + 1), texte_streaming.length);
- ligne_occupee = texte_streaming.substring((texte_streaming.indexOf("(#") + 6), texte_streaming.indexOf("/"));
- trace("- Lignes occupées : " + ligne_occupee);
- ligne_disponible = texte_streaming.substring((texte_streaming.indexOf("/") + 1), texte_streaming.indexOf(")"));
- trace("- Lignes disponibles : " + ligne_disponible);
- if (ligne_occupee == null && ligne_disponible == null || ligne_occupee == "" && ligne_disponible == "") serveur_invalide = true;
- if (ligne_occupee == ligne_disponible) serveur_sature = true;
- if (serveur_sature) status_connexion = "STATION INDISPONIBLE";
- else if (serveur_invalide) status_connexion = "STATION NON VALIDE";
- else
- {
- station_texte = controle_texte_affichage(nom_station);
- if (!etat_aac) ouverture_flux_mp3();
- else initialisation_connexion(null);
- }
- }
- else status_connexion = "PLS ABSENT";
- }
- private function fin_chargement_fichier_xls(e:Event):void
- {
- trace(e.target.data);
- var texte:String = new String(e.target.data);
- var tableau:Array;
- if (texte.indexOf("<title>", 0) != - 1)
- {
- texte = texte.substr(texte.indexOf("<title>", 0), texte.indexOf("</title>", 0)).replace("<title>", "").replace("</title>", "");
- if (texte.indexOf("Artiste", 0) != - 1 && texte.indexOf("Titre", 0)) tableau = texte.replace("Artiste : ", "").split(" Titre : ")
- else if (texte.indexOf(" - ", 0) != -1) tableau = texte.split(" - ");
- else if (texte.indexOf(" § ", 0) != -1) tableau = texte.split(" § ");
- else tableau[0] = texte;
- if (tableau[0] == null) tableau[0] = "---";
- if (tableau[1] == null) tableau[1] = "---";
- artiste_musique = controle_texte_affichage(tableau[0]);
- titre_musique = controle_texte_affichage(tableau[1]);
- etat_meta = true;
- trace("- Méta Ok");
- }
- else trace("- Méta non present");
- }
- private function fin_chargement_meta(e:Event):void
- {
- var chargeur_local:URLLoader = URLLoader(e.target);
- chargeur_local.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
- etat_meta = false;
- var texte:String = unescape(chargeur_local.data.toString());
- trace("- Méta données : " + texte);
- var tableau:Array = new Array();
- if (texte.indexOf("StreamTitle") != -1 && texte.indexOf("Information Not Entered by Broadcaster") == -1)
- {
- tableau = texte.split("&StreamUrl");
- texte = tableau[0].substring(tableau[0].indexOf("='") + 2, tableau[0].length - 1);
- tableau = texte.split(" - ")
- if (tableau[0] == null) tableau[0] = "---";
- if (tableau[1] == null) tableau[1] = "---";
- artiste_musique = controle_texte_affichage(tableau[0]);
- titre_musique = controle_texte_affichage(tableau[1]);
- trace("- Méta Ok");
- etat_meta = true;
- return;
- }
- if (texte.indexOf("404") != -1) trace("- Erreur 404");
- else trace("- Méta non disponible");
- }
- private function action_timer_flux(e:TimerEvent):void
- {
- if (!etat_aac)
- {
- var taille:int = son_flux.bytesLoaded / 1000000;
- if ((taille > 5) && etat_cache)
- {
- arret_lecteur();
- ouverture_flux_mp3();
- }
- }
- gestion_bargraph(compteur_barre, -1);
- compteur_barre++;
- if (compteur_barre >= 10) compteur_barre = 0;
- gestion_volume();
- }
- private function action_timer_affichage(e:TimerEvent):void
- {
- if (etat_meta)
- {
- switch (rotation_affichage)
- {
- case 0 :
- lecteur.texte_connexion.text = status_connexion;
- break;
- case 150 :
- recuperation_meta_donnee();
- break;
- case 300 :
- lecteur.texte_connexion.text = artiste_musique;
- break;
- case 600 :
- lecteur.texte_connexion.text = titre_musique;
- break;
- case 899 :
- rotation_affichage = -1;
- }
- rotation_affichage++;
- }
- else lecteur.texte_connexion.text = status_connexion;
- lecteur.spirale.rotation += 1;
- if (lecteur.spirale.rotation >= 360) lecteur.spirale.rotation = 0;
- if (!etat_proxy) lecteur.voyant_proxy.visible = false;
- else lecteur.voyant_proxy.visible = true;
- if (!etat_aac) lecteur.voyant_aac.visible = false;
- else lecteur.voyant_aac.visible = true;
- lecteur.texte_station.text = defilement_texte(station_texte);
- }
- private function gestion_erreur_chargement(e:IOErrorEvent):void
- {
- trace("- Erreur chargement !");
- status_connexion = "ERREUR CHARGEMENT"
- lecteur.voyant_erreur_chargement.visible = true;
- etat_marche = false;
- timer_flux.stop();
- }
- private function gestion_erreur_securite(e:SecurityErrorEvent):void
- {
- trace("- Erreur sécurité !");
- status_connexion = "ERREUR SECURITE : ";
- lecteur.voyant_erreur_securite.visible = true;
- etat_marche = false;
- timer_flux.stop();
- }
- private function gestion_progression_chargement(e:ProgressEvent):void
- {
- status_connexion = "CONNECTE";
- if (!etat_marche)
- {
- etat_marche = true;
- operation_en_cours = false;
- timer_flux.start();
- recuperation_meta_donnee();
- }
- }
- private function action_bouton_play(e:MouseEvent):void
- {
- if (parametre_station == null)
- {
- //pointeur_station = int(Math.random() * liste_station.length);
- pointeur_station = 0;
- parametre_station = liste_station[pointeur_station];
- lecture_information_station();
- }
- else if (liste_station[pointeur_station] != parametre_station && parametre_station.indexOf("http://", 0) == - 1)
- {
- lecteur.bouton_selection_station.visible = false;
- arret_lecteur();
- parametre_station = liste_station[pointeur_station];
- lecture_information_station();
- }
- else lancer_lecteur("IDEM", null);
- gestion_affichage_station();
- }
- private function action_bouton_stop(e:MouseEvent):void
- {
- arret_lecteur();
- }
- private function gestion_status_reseau(e:NetStatusEvent):void
- {
- switch (e.info.code)
- {
- case "NetConnection.Connect.Success" :
- ouverture_flux_aac();
- break;
- case "NetConnection.Connect.Closed" :
- break;
- case "NetStream.Play.StreamNotFound" :
- arret_lecteur();
- break;
- case "NetStream.Play.PublishNotify" :
- break;
- case "NetStream.Play.UnpublishNotify" :
- arret_lecteur();
- break;
- case "NetStream.Play.Reset" :
- break;
- case "NetStream.Play.Start" :
- break;
- case "NetStream.Buffer.Full" :
- timer_flux.start();
- etat_marche = true;
- status_connexion = "CONNECTE";
- operation_en_cours = false;
- recuperation_meta_donnee();
- }
- trace("- " + e.info.code);
- }
- private function erreur_asynchrone_reseau(e:AsyncErrorEvent):void
- {
- trace("- Erreur synchronisation !");
- }
- private function action_bouton_volume_up(e:MouseEvent):void {modification_volume = false;}
- private function action_bouton_volume_down(e:MouseEvent):void {modification_volume = true;}
- private function action_bouton_volume_move(e:MouseEvent):void
- {
- if (modification_volume && (e.stageX > 22) && (e.stageX < 106)) lecteur.bouton_volume.x = e.stageX;
- }
- private function action_bouton_station_plus(e:MouseEvent):void
- {
- if (liste_station.length == 0) return;
- pointeur_station++;
- if (pointeur_station >= liste_station.length) pointeur_station = 0;
- gestion_affichage_station();
- }
- private function action_bouton_station_moins(e:MouseEvent):void
- {
- if (liste_station.length == 0) return;
- pointeur_station--;
- if (pointeur_station < 0) pointeur_station = liste_station.length - 1;
- gestion_affichage_station();
- }
- private function action_bouton_flux(e:MouseEvent):void
- {
- if (operation_en_cours) return;
- var test_flux:String = null;
- var parametre_1:String;
- var parametre_2:String;
- var issue_de_secours:int = 0;
- while (test_flux == null)
- {
- pointeur_flux++;
- if (pointeur_flux > 3) pointeur_flux = 0;
- switch (pointeur_flux)
- {
- case 0 :
- test_flux = flux_mp3_haut;
- parametre_1 = "H";
- parametre_2 = "MP3";
- break;
- case 1 :
- test_flux = flux_mp3_bas;
- parametre_1 = "L";
- parametre_2 = "MP3";
- break;
- case 2 :
- test_flux = flux_rtmp_haut;
- parametre_1 = "H";
- parametre_2 = "AAC";
- break;
- case 3 :
- test_flux = flux_rtmp_bas;
- parametre_1 = "L";
- parametre_2 = "AAC";
- }
- issue_de_secours++;
- if (issue_de_secours > 5) return;
- }
- arret_lecteur();
- lancer_lecteur(parametre_2, parametre_1);
- }
- private function action_bouton_selection_station(e:MouseEvent):void
- {
- lecteur.bouton_selection_station.visible = false;
- arret_lecteur();
- parametre_station = liste_station[pointeur_station];
- lecture_information_station();
- }
- // Fenêtre de paramètrages
- private function action_touche_enfoncee(e:KeyboardEvent):void
- {
- if (e.keyCode == Keyboard.ENTER)
- {
- trace(FENETRE_SAISIE.texte_saisie.text);
- action_bouton_quitter_saisie(null);
- arret_lecteur();
- parametre_station = FENETRE_SAISIE.texte_saisie.text;
- lecture_information_station();
- }
- }
- private function action_bouton_saisie_flux(e:MouseEvent):void
- {
- addChild(FENETRE_SAISIE);
- FENETRE_SAISIE.x = 25;
- FENETRE_SAISIE.y = 7.5;
- FENETRE_SAISIE.alpha = .85
- FENETRE_SAISIE.bouton_quitter_saisie.addEventListener(MouseEvent.CLICK, action_bouton_quitter_saisie);
- FENETRE_SAISIE.texte_saisie.addEventListener(MouseEvent.CLICK, action_commencer_saisie);
- FENETRE_SAISIE.bouton_cache.addEventListener(MouseEvent.CLICK, action_bouton_cache);
- FENETRE_SAISIE.bouton_proxy.addEventListener(MouseEvent.CLICK, action_bouton_proxy);
- FENETRE_SAISIE.bouton_liste_1.addEventListener(MouseEvent.CLICK, action_bouton_liste_1);
- FENETRE_SAISIE.bouton_liste_2.addEventListener(MouseEvent.CLICK, action_bouton_liste_2);
- FENETRE_SAISIE.bouton_cache.buttonMode = true;
- FENETRE_SAISIE.bouton_proxy.buttonMode = true;
- FENETRE_SAISIE.bouton_liste_1.buttonMode = true;
- FENETRE_SAISIE.bouton_liste_2.buttonMode = true;
- action_bouton_cache(null);
- action_bouton_proxy(null);
- if (numero_liste == 1) action_bouton_liste_1(null);
- else action_bouton_liste_2(null);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, action_touche_enfoncee);
- }
- private function action_bouton_quitter_saisie(e:MouseEvent):void
- {
- FENETRE_SAISIE.bouton_quitter_saisie.removeEventListener(MouseEvent.CLICK, action_bouton_quitter_saisie);
- FENETRE_SAISIE.texte_saisie.removeEventListener(MouseEvent.CLICK, action_commencer_saisie);
- FENETRE_SAISIE.bouton_cache.removeEventListener(MouseEvent.CLICK, action_bouton_cache);
- FENETRE_SAISIE.bouton_proxy.removeEventListener(MouseEvent.CLICK, action_bouton_proxy);
- FENETRE_SAISIE.bouton_liste_1.removeEventListener(MouseEvent.CLICK, action_bouton_liste_1);
- FENETRE_SAISIE.bouton_liste_2.removeEventListener(MouseEvent.CLICK, action_bouton_liste_2);
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, action_touche_enfoncee);
- removeChild(this.FENETRE_SAISIE);
- }
- private function action_commencer_saisie(e:MouseEvent):void
- {
- if (!une_fois)
- {
- une_fois = true;
- FENETRE_SAISIE.texte_saisie.text = "";
- }
- }
- private function action_bouton_cache(e:MouseEvent):void
- {
- if (e != null) etat_cache = !etat_cache;
- if (etat_cache) FENETRE_SAISIE.bouton_cache.alpha = 1;
- else FENETRE_SAISIE.bouton_cache.alpha = .4;
- }
- private function action_bouton_proxy(e:MouseEvent):void
- {
- if (e != null) etat_proxy = !etat_proxy;
- if (etat_proxy) FENETRE_SAISIE.bouton_proxy.alpha = 1;
- else FENETRE_SAISIE.bouton_proxy.alpha = .4;
- }
- private function action_bouton_liste_1(e:MouseEvent):void
- {
- FENETRE_SAISIE.bouton_liste_1.alpha = 1;
- FENETRE_SAISIE.bouton_liste_2.alpha = .4;
- numero_liste = 1;
- if (e != null) chargement_liste_xml(parametre_liste_1);
- }
- private function action_bouton_liste_2(e:MouseEvent):void
- {
- FENETRE_SAISIE.bouton_liste_1.alpha = .4;
- FENETRE_SAISIE.bouton_liste_2.alpha = 1;
- numero_liste = 2;
- if (e != null) chargement_liste_xml(parametre_liste_2);
- }
- }
- }
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.utils.Timer;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundTransform;
import flash.media.SoundChannel;
import flash.ui.Keyboard;
public class erystreaming extends MovieClip
{
const INFOMANIAK :String = new String("http://<station>.ice.infomaniak.ch.ice.infomaniak.ch/meta.xsl?mount=/<station>-high.mp3");
const STATSLIVE :String = new String("http://statslive.infomaniak.ch/player/xml/");
const BROADCAST :String = new String("http://broadcast.infomaniak.ch/player/");
const VERIFAAC :String = new String("http://statslive.infomaniak.ch/player/xml/verifAAC.php?fic=");
const SHOUTCAST :String = new String("http://yp.shoutcast.com/sbin/tunein-station.pls?id=");
const PHP_SHOUTCAST :String = new String("http://yp.shoutcast.com/Metadata_Info1.php");
const PROXY_STREAMING :String = new String("http://www.erysoft.fr/test/erystreaming/streaxy.php");
const LISTE_INFOMANIAK :String = new String("http://www.erysoft.fr/test/erystreaming/station_1.xml");
const LISTE_SHOUTCAST :String = new String("http://www.erysoft.fr/test/erystreaming/station_2.xml");
const ESPACE :String = new String(" ");
const MODE_INFOMANIAK :int = 1;
const MODE_URL :int = 2;
const MODE_SHOUTCAST :int = 3;
const FENETRE_SAISIE :fenetre_saisie_flux = new fenetre_saisie_flux;
var liste_station :Array;
var parametre :Object = loaderInfo.parameters;
var parametre_station :String = parametre.sta;
var parametre_volume :String = parametre.vol;
var parametre_nom :String = parametre.nom;
var parametre_auto :String = parametre.aut;
var parametre_proxy :String = parametre.pro;
var parametre_liste_1 :String = parametre.lis1;
var parametre_liste_2 :String = parametre.lis2;
var timer_flux :Timer;
var timer_affichage :Timer;
var son_flux :Sound;
var canal_flux :SoundChannel;
var effet_flux :SoundTransform;
var connexion_reseau :NetConnection;
var flux_audio :NetStream;
var flux_mp3_haut :String;
var flux_mp3_bas :String;
var nom_station :String;
var serveur_rtmp :String;
var repertoire_rtmp :String;
var flux_rtmp_haut :String;
var flux_rtmp_bas :String;
var test_rtmp_haut :String;
var test_rtmp_bas :String;
var domaine_station :String;
var flux_courant :String;
var titre_musique :String;
var artiste_musique :String;
var status_connexion :String = "ERYSTREAMING V2.05";
var racine_rtmp :String;
var texte_defilant :String;
var station_texte :String;
var memoire_texte :String;
var volume_streaming :Number;
var pointeur_station :int = 0;
var pointeur_flux :int = 0;
var mode_streaming :int = 0;
var compteur_barre :int = 0;
var rotation_affichage :int = 0;
var numero_liste :int = 0;
var compteur_defilement :int = 0;
var debug_xml :Boolean = false;
var test_acc_haut_bas :Boolean;
var etat_aac :Boolean = false;
var etat_marche :Boolean = false;
var modification_volume :Boolean = false;
var etat_proxy :Boolean = true;
var une_fois :Boolean = false;
var etat_cache :Boolean = true;
var etat_meta :Boolean = false;
var operation_en_cours :Boolean = false;
public function erystreaming():void
{
if (parametre_proxy == null) parametre_proxy = PROXY_STREAMING;
if (parametre_liste_1 == null) parametre_liste_1 = LISTE_INFOMANIAK;
if (parametre_liste_2 == null) parametre_liste_2 = LISTE_SHOUTCAST;
chargement_liste_xml(parametre_liste_1);
numero_liste = 1;
if (parametre_volume == null) volume_streaming = 0.75;
else volume_streaming = int(parametre_volume) / 100
lecteur.bouton_volume.x = 23 + 82 * volume_streaming;
this.lecteur.bouton_play.addEventListener(MouseEvent.CLICK, action_bouton_play);
this.lecteur.bouton_stop.addEventListener(MouseEvent.CLICK, action_bouton_stop);
this.lecteur.bouton_station_plus.addEventListener(MouseEvent.CLICK, action_bouton_station_plus);
this.lecteur.bouton_station_moins.addEventListener(MouseEvent.CLICK, action_bouton_station_moins);
this.lecteur.bouton_saisie_flux.addEventListener(MouseEvent.CLICK, action_bouton_saisie_flux);
this.lecteur.bouton_flux.addEventListener(MouseEvent.CLICK, action_bouton_flux);
this.lecteur.bouton_selection_station.addEventListener(MouseEvent.CLICK, action_bouton_selection_station);
this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_DOWN, action_bouton_volume_down);
this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_OUT, action_bouton_volume_up);
this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_UP, action_bouton_volume_up);
this.lecteur.bouton_volume.addEventListener(MouseEvent.MOUSE_MOVE, action_bouton_volume_move);
lecteur.bouton_volume.buttonMode = true;
lecteur.bouton_selection_station.visible = false;
lecteur.bouton_flux.visible = false;
eteindre_voyant_controle();
initialisation_bargraph();
timer_affichage = new Timer(10);
timer_affichage.addEventListener(TimerEvent.TIMER, action_timer_affichage);
timer_affichage.start();
timer_flux = new Timer(10);
timer_flux.addEventListener(TimerEvent.TIMER, action_timer_flux);
if (!etat_proxy) lecteur.voyant_proxy.visible = false;
else lecteur.voyant_proxy.visible = true;
if (parametre_auto) action_bouton_play(null);
}
private function lecture_information_station():void
{
eteindre_voyant_controle();
if (!etat_proxy) lecteur.voyant_proxy.visible = false;
else lecteur.voyant_proxy.visible = true;
status_connexion = "CONNEXION EN COURS";
if (parametre_station.indexOf("|") != -1)
{
mode_streaming = MODE_SHOUTCAST;
lecteur.bouton_flux.visible = false;
var tableau:Array = parametre_station.split("|");
etat_aac = false;
if (tableau[2] == "AAC") etat_aac = true;
if (etat_proxy) chargement_fichier_pls_proxy(parametre_proxy, tableau[0]);
else chargement_fichier_pls(SHOUTCAST + tableau[0]);
}
else if (parametre_station.indexOf("http://") != -1)
{
mode_streaming = MODE_URL;
flux_courant = parametre_station;
ouverture_flux_mp3();
station_texte = parametre_station;
}
else
{
mode_streaming = MODE_INFOMANIAK;
lecteur.bouton_flux.visible = true;
var adresse:String;
if (debug_xml) adresse = STATSLIVE;
else adresse = BROADCAST;
adresse += "configuration_" + parametre_station + ".xml?time=" + new Date().getTime();
trace("- Xml : " + adresse);
chargement_fichier_xml(adresse);
}
}
private function chargement_liste_xml(url_liste:String):void
{
var chargeur_xml:URLLoader = new URLLoader(new URLRequest(url_liste));
chargeur_xml.addEventListener(Event.COMPLETE, fin_chargement_liste_xml);
chargeur_xml.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_xml.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_pls(url_pls:String):void
{
var chargeur_pls:URLLoader = new URLLoader(new URLRequest(url_pls + "&file=filename.pls"));
chargeur_pls.addEventListener(Event.COMPLETE, fin_chargement_pls);
chargeur_pls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_pls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_pls_proxy(url_proxy:String, parametre:String):void
{
parametre += "&time=" + new Date().getTime();
var chargeur_pls:URLLoader = new URLLoader(new URLRequest(url_proxy + "?hdr=0&opt=pls&par=" + parametre));
chargeur_pls.addEventListener(Event.COMPLETE, fin_chargement_pls);
chargeur_pls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_pls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_meta(url_meta:String):void
{
var chargeur_meta:URLLoader = new URLLoader(new URLRequest(url_meta + "?surl=" + flux_courant));
chargeur_meta.addEventListener(Event.COMPLETE, fin_chargement_meta);
chargeur_meta.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_meta.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_meta_proxy(url_proxy:String):void
{
var parametre:String = flux_courant.substring(7, flux_courant.length) + "&time=" + new Date().getTime();
var chargeur_meta:URLLoader = new URLLoader(new URLRequest(url_proxy + "?hdr=0&opt=meta&par=" + parametre));
chargeur_meta.addEventListener(Event.COMPLETE, fin_chargement_meta);
chargeur_meta.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_meta.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_xls(url_xls:String):void
{
var parametre:String = "&time=" + new Date().getTime();
var chargeur_xls:URLLoader = new URLLoader(new URLRequest(url_xls.replace(/<station>/gi, domaine_station) + parametre));
chargeur_xls.addEventListener(Event.COMPLETE, fin_chargement_fichier_xls);
chargeur_xls.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_xls.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_fichier_xml(url_xml:String):void
{
var chargeur_xml:URLLoader = new URLLoader(new URLRequest(url_xml));
chargeur_xml.addEventListener(Event.COMPLETE, fin_chargement_fichier_xml);
chargeur_xml.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_xml.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function chargement_rtmp_information(url_rtmp_info:String):void
{
var chargeur_rtmp:URLLoader = new URLLoader(new URLRequest(url_rtmp_info));
chargeur_rtmp.addEventListener(Event.COMPLETE, fin_chargement_rtmp);
chargeur_rtmp.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
chargeur_rtmp.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
}
private function preparation_lecteur():void
{
station_texte = controle_texte_affichage(nom_station);
if (flux_mp3_haut != null) flux_mp3_haut = "http://" + domaine_station + ".ice.infomaniak.ch" + flux_mp3_haut;
if (flux_mp3_bas != null) flux_mp3_bas = "http://" + domaine_station + ".ice.infomaniak.ch" + flux_mp3_bas;
if (flux_rtmp_haut != null) test_rtmp_haut = VERIFAAC + flux_rtmp_haut;
if (flux_rtmp_bas != null) test_rtmp_bas = VERIFAAC + flux_rtmp_bas;
racine_rtmp = serveur_rtmp + "/" + repertoire_rtmp;
trace("- Flux mp3 haut : " + flux_mp3_haut);
trace("- Flux mp3 bas : " + flux_mp3_bas);
trace("- Flux Rtmp haut : " + flux_rtmp_haut);
trace("- Flux Rtmp bas : " + flux_rtmp_bas);
trace("- Test Rtmp haut : " + test_rtmp_haut);
trace("- Test Rtmp bas : " + test_rtmp_bas);
trace("- Racine Rtmp : " + racine_rtmp);
test_acc_haut_bas = true;
if (test_rtmp_haut != null) chargement_rtmp_information(test_rtmp_haut);
else lancer_lecteur(null, null);
}
private function lancer_lecteur(comment:String, debit:String):void
{
if (etat_marche) return;
initialisation_bargraph();
eteindre_voyant_controle();
etat_aac = false;
operation_en_cours = true;
if (comment == null)
{
if (flux_rtmp_haut != null)
{
flux_courant = flux_rtmp_haut;
initialisation_connexion(racine_rtmp);
lecteur.texte_flux.text = "AAC-H";
pointeur_flux = 2;
}
else
{
flux_courant = flux_mp3_haut;
ouverture_flux_mp3();
lecteur.texte_flux.text = "MP3-H";
pointeur_flux = 0;
}
}
else if (comment == "IDEM")
{
if (flux_courant.toLowerCase().indexOf(".aac",0) != -1) initialisation_connexion(racine_rtmp);
else ouverture_flux_mp3();
}
else if (comment == "AAC")
{
if (debit == "H")
{
flux_courant = flux_rtmp_haut;
lecteur.texte_flux.text = "AAC-H";
}
else
{
flux_courant = flux_rtmp_bas;
lecteur.texte_flux.text = "AAC-L";
}
if (flux_courant != null) initialisation_connexion(racine_rtmp);
else lecteur.texte_flux.text = "---";
}
else if (comment == "MP3")
{
if (debit == "H")
{
flux_courant = flux_mp3_haut;
lecteur.texte_flux.text = "MP3-H";
}
else
{
flux_courant = flux_mp3_bas;
lecteur.texte_flux.text = "MP3-L";
}
if (flux_courant != null) ouverture_flux_mp3();
else lecteur.texte_flux.text = "---";
}
else lecteur.texte_flux.text = "---";
}
private function arret_lecteur():void
{
initialisation_bargraph();
etat_marche = false;
etat_meta = false;
operation_en_cours = false;
if (etat_aac)
{
try {flux_audio.close();}
catch(e:Error) {}
}
else
{
try
{
son_flux.close();
canal_flux.stop();
}
catch(e:Error) {}
}
try {timer_flux.stop();}
catch(e:Error) {}
status_connexion = "DECONNECTE";
}
private function ouverture_flux_mp3():void
{
if ( flux_courant.toLowerCase().indexOf(".mp3", 0) == - 1) son_flux = new Sound(new URLRequest(flux_courant + "/;pipi_caca_popo.mp3"));
else son_flux = new Sound(new URLRequest(flux_courant));
canal_flux = new SoundChannel();
effet_flux = new SoundTransform();
son_flux.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
son_flux.addEventListener(ProgressEvent.PROGRESS, gestion_progression_chargement);
canal_flux = son_flux.play();
effet_flux.volume = volume_streaming;
effet_flux.pan = 0;
canal_flux.soundTransform = effet_flux;
}
private function initialisation_connexion(url_net:String):void
{
etat_aac = true;
connexion_reseau = new NetConnection();
connexion_reseau.addEventListener(NetStatusEvent.NET_STATUS, gestion_status_reseau);
connexion_reseau.addEventListener(AsyncErrorEvent.ASYNC_ERROR, erreur_asynchrone_reseau);
connexion_reseau.connect(url_net);
}
private function ouverture_flux_aac():void
{
effet_flux = new SoundTransform();
flux_audio = new NetStream(connexion_reseau);
flux_audio.addEventListener(NetStatusEvent.NET_STATUS, gestion_status_reseau);
flux_audio.addEventListener(SecurityErrorEvent.SECURITY_ERROR, gestion_erreur_securite);
flux_audio.addEventListener(AsyncErrorEvent.ASYNC_ERROR, erreur_asynchrone_reseau);
flux_audio.bufferTime = Number(5);
flux_audio.play(flux_courant);
effet_flux.volume = volume_streaming;
flux_audio.soundTransform = effet_flux;
}
private function gestion_volume():void
{
volume_streaming = (lecteur.bouton_volume.x - 23) / 82
effet_flux = new SoundTransform();
effet_flux.volume = volume_streaming;
effet_flux.pan = 0;
if (etat_aac) flux_audio.soundTransform = effet_flux;
else canal_flux.soundTransform = effet_flux;
}
private function gestion_bargraph(numero:int, valeur:int):void
{
var objet:Object = new Object();
switch (numero)
{
case 0 : objet = lecteur.bargraph.barre_0; break;
case 1 : objet = lecteur.bargraph.barre_1; break;
case 2 : objet = lecteur.bargraph.barre_2; break;
case 3 : objet = lecteur.bargraph.barre_3; break;
case 4 : objet = lecteur.bargraph.barre_4; break;
case 5 : objet = lecteur.bargraph.barre_5; break;
case 6 : objet = lecteur.bargraph.barre_6; break;
case 7 : objet = lecteur.bargraph.barre_7; break;
case 8 : objet = lecteur.bargraph.barre_8; break;
case 9 : objet = lecteur.bargraph.barre_9;
}
if (valeur >= 0) objet.height = valeur;
else if (etat_aac) objet.height = int(20 * Math.random()) + 10;
else
{
if (numero < 6) objet.height = int(40 * canal_flux.leftPeak);
else objet.height = int(40 * canal_flux.rightPeak);
}
objet.y = 40 - objet.height;
}
private function initialisation_bargraph():void
{
for (var i:int = 0; i < 10; i++) gestion_bargraph(i, 1);
}
private function gestion_affichage_station():void
{
if (liste_station[pointeur_station] != parametre_station) lecteur.bouton_selection_station.visible = true;
else lecteur.bouton_selection_station.visible = false;
if (liste_station[pointeur_station].indexOf("|") != - 1)
{
var table:Array = liste_station[pointeur_station].split("|");
station_texte = controle_texte_affichage(table[1]);
}
else station_texte = controle_texte_affichage(liste_station[pointeur_station]);
}
private function initialisation_variable():void
{
flux_mp3_haut = null;
flux_mp3_bas = null;
nom_station = null;
serveur_rtmp = null;
repertoire_rtmp = null;
flux_rtmp_haut = null;
flux_rtmp_bas = null;
test_rtmp_haut = null;
test_rtmp_bas = null;
domaine_station = null;
flux_courant = null;
racine_rtmp = null;
}
private function eteindre_voyant_controle():void
{
lecteur.voyant_erreur_securite.visible = false;
lecteur.voyant_erreur_chargement.visible = false;
}
private function controle_texte_affichage(texte:String):String
{
var reponse:String = new String("");
texte = texte.replace("à","a").replace("é","e").replace("è","e").replace("ë","e").replace("ê","e").replace("ù","u").replace("ç","c").replace("ô","o");
for (var i:int = 0; i < texte.length; i++)
{
if (texte.charCodeAt(i) >= 0x20 && texte.charCodeAt(i) < 0x7F) reponse += texte.charAt(i);
}
return reponse;
}
private function recuperation_meta_donnee():void
{
switch (mode_streaming)
{
case MODE_SHOUTCAST :
if (etat_proxy) chargement_fichier_meta_proxy(parametre_proxy);
else chargement_fichier_meta(PHP_SHOUTCAST);
break;
case MODE_URL :
break;
case MODE_INFOMANIAK :
chargement_fichier_xls(INFOMANIAK);
}
}
private function defilement_texte(texte:String):String
{
if (texte == null) return "";
if (!etat_marche || lecteur.bouton_selection_station.visible) return texte;
compteur_defilement++;
if (compteur_defilement > 20) compteur_defilement = 0;
if (texte != memoire_texte)
{
texte_defilant = texte;
memoire_texte = texte;
}
if (compteur_defilement == 0)
{
if (texte_defilant.length > 0) texte_defilant = texte_defilant.substr(1, texte_defilant.length);
else texte_defilant = ESPACE + texte;
}
return texte_defilant;
}
// Evènements -------------------------------------------------------------------------------------------------------------
private function fin_chargement_liste_xml(e:Event):void
{
liste_station = new Array();
var texte:XML = new XML(e.target.data);
texte.ignoreWhitespace;
var lignes:XMLList = texte.elements();
for each (var ligne:XML in lignes) liste_station.push(ligne.@nom.toString());
pointeur_station = 0;
gestion_affichage_station();
}
private function fin_chargement_fichier_xml(e:Event):void
{
initialisation_variable();
var texte:XML = new XML(e.target.data);
texte.ignoreWhitespace;
var lignes:XMLList = texte.elements();
for each (var ligne:XML in lignes)
{
switch (ligne.@name.toString())
{
case "sFeedHigh" : flux_mp3_haut = ligne.@value; break;
case "sFeedLow" : flux_mp3_bas = ligne.@value; break;
case "sNomRadio" : nom_station = ligne.@value; break;
case "sRtmpServer" : serveur_rtmp = ligne.@value; break;
case "sRtmpDir" : repertoire_rtmp = ligne.@value; break;
case "sRtmpFeedHigh" : flux_rtmp_haut = ligne.@value; break;
case "sRtmpFeedLow" : flux_rtmp_bas = ligne.@value; break;
case "sDomain" : domaine_station = ligne.@value; break;
default : trace("< Paramètre inconnu ou ignoré >");
}
trace("- " + ligne.@name + " : " + ligne.@value);
if (domaine_station == null) domaine_station = flux_mp3_haut.substr(0, flux_mp3_haut.indexOf("-",0));
}
preparation_lecteur();
}
private function fin_chargement_rtmp(e:Event):void
{
var texte:String = new String(e.target.data);
if (test_acc_haut_bas)
{
if (texte == "done2=1")
{
trace("- Rtmp High actif");
test_acc_haut_bas = false;
if (test_rtmp_bas != null)
{
chargement_rtmp_information(test_rtmp_bas);
return;
}
}
else
{
trace("- Rtmp High inactif");
flux_rtmp_haut = null;
}
}
else
{
if (texte == "done2=1") trace("- Rtmp Low actif");
else
{
trace("- Rtmp Low inactif");
flux_rtmp_bas = null;
}
}
lancer_lecteur(null, null);
}
private function fin_chargement_pls(e:Event):void
{
var adresse_streaming:String = null;
var texte_streaming:String = null;
var ligne_occupee:String = null;
var ligne_disponible:String = null;
var ligne:Array = new Array();
var serveur_invalide:Boolean = false;
var serveur_sature:Boolean = false;
flux_courant = null;
nom_station = null;
trace("- Fichier pls chargé : \n" + e.currentTarget.data);
ligne = e.currentTarget.data.split("\n");
if (ligne[0] == "[playlist]")
{
adresse_streaming = ligne[2].toString();
flux_courant = adresse_streaming.substring((adresse_streaming.indexOf("=") + 1), adresse_streaming.length);
texte_streaming = ligne[3].toString();
nom_station = texte_streaming.substring((texte_streaming.indexOf(")") + 1), texte_streaming.length);
ligne_occupee = texte_streaming.substring((texte_streaming.indexOf("(#") + 6), texte_streaming.indexOf("/"));
trace("- Lignes occupées : " + ligne_occupee);
ligne_disponible = texte_streaming.substring((texte_streaming.indexOf("/") + 1), texte_streaming.indexOf(")"));
trace("- Lignes disponibles : " + ligne_disponible);
if (ligne_occupee == null && ligne_disponible == null || ligne_occupee == "" && ligne_disponible == "") serveur_invalide = true;
if (ligne_occupee == ligne_disponible) serveur_sature = true;
if (serveur_sature) status_connexion = "STATION INDISPONIBLE";
else if (serveur_invalide) status_connexion = "STATION NON VALIDE";
else
{
station_texte = controle_texte_affichage(nom_station);
if (!etat_aac) ouverture_flux_mp3();
else initialisation_connexion(null);
}
}
else status_connexion = "PLS ABSENT";
}
private function fin_chargement_fichier_xls(e:Event):void
{
trace(e.target.data);
var texte:String = new String(e.target.data);
var tableau:Array;
if (texte.indexOf("<title>", 0) != - 1)
{
texte = texte.substr(texte.indexOf("<title>", 0), texte.indexOf("</title>", 0)).replace("<title>", "").replace("</title>", "");
if (texte.indexOf("Artiste", 0) != - 1 && texte.indexOf("Titre", 0)) tableau = texte.replace("Artiste : ", "").split(" Titre : ")
else if (texte.indexOf(" - ", 0) != -1) tableau = texte.split(" - ");
else if (texte.indexOf(" § ", 0) != -1) tableau = texte.split(" § ");
else tableau[0] = texte;
if (tableau[0] == null) tableau[0] = "---";
if (tableau[1] == null) tableau[1] = "---";
artiste_musique = controle_texte_affichage(tableau[0]);
titre_musique = controle_texte_affichage(tableau[1]);
etat_meta = true;
trace("- Méta Ok");
}
else trace("- Méta non present");
}
private function fin_chargement_meta(e:Event):void
{
var chargeur_local:URLLoader = URLLoader(e.target);
chargeur_local.addEventListener(IOErrorEvent.IO_ERROR, gestion_erreur_chargement);
etat_meta = false;
var texte:String = unescape(chargeur_local.data.toString());
trace("- Méta données : " + texte);
var tableau:Array = new Array();
if (texte.indexOf("StreamTitle") != -1 && texte.indexOf("Information Not Entered by Broadcaster") == -1)
{
tableau = texte.split("&StreamUrl");
texte = tableau[0].substring(tableau[0].indexOf("='") + 2, tableau[0].length - 1);
tableau = texte.split(" - ")
if (tableau[0] == null) tableau[0] = "---";
if (tableau[1] == null) tableau[1] = "---";
artiste_musique = controle_texte_affichage(tableau[0]);
titre_musique = controle_texte_affichage(tableau[1]);
trace("- Méta Ok");
etat_meta = true;
return;
}
if (texte.indexOf("404") != -1) trace("- Erreur 404");
else trace("- Méta non disponible");
}
private function action_timer_flux(e:TimerEvent):void
{
if (!etat_aac)
{
var taille:int = son_flux.bytesLoaded / 1000000;
if ((taille > 5) && etat_cache)
{
arret_lecteur();
ouverture_flux_mp3();
}
}
gestion_bargraph(compteur_barre, -1);
compteur_barre++;
if (compteur_barre >= 10) compteur_barre = 0;
gestion_volume();
}
private function action_timer_affichage(e:TimerEvent):void
{
if (etat_meta)
{
switch (rotation_affichage)
{
case 0 :
lecteur.texte_connexion.text = status_connexion;
break;
case 150 :
recuperation_meta_donnee();
break;
case 300 :
lecteur.texte_connexion.text = artiste_musique;
break;
case 600 :
lecteur.texte_connexion.text = titre_musique;
break;
case 899 :
rotation_affichage = -1;
}
rotation_affichage++;
}
else lecteur.texte_connexion.text = status_connexion;
lecteur.spirale.rotation += 1;
if (lecteur.spirale.rotation >= 360) lecteur.spirale.rotation = 0;
if (!etat_proxy) lecteur.voyant_proxy.visible = false;
else lecteur.voyant_proxy.visible = true;
if (!etat_aac) lecteur.voyant_aac.visible = false;
else lecteur.voyant_aac.visible = true;
lecteur.texte_station.text = defilement_texte(station_texte);
}
private function gestion_erreur_chargement(e:IOErrorEvent):void
{
trace("- Erreur chargement !");
status_connexion = "ERREUR CHARGEMENT"
lecteur.voyant_erreur_chargement.visible = true;
etat_marche = false;
timer_flux.stop();
}
private function gestion_erreur_securite(e:SecurityErrorEvent):void
{
trace("- Erreur sécurité !");
status_connexion = "ERREUR SECURITE : ";
lecteur.voyant_erreur_securite.visible = true;
etat_marche = false;
timer_flux.stop();
}
private function gestion_progression_chargement(e:ProgressEvent):void
{
status_connexion = "CONNECTE";
if (!etat_marche)
{
etat_marche = true;
operation_en_cours = false;
timer_flux.start();
recuperation_meta_donnee();
}
}
private function action_bouton_play(e:MouseEvent):void
{
if (parametre_station == null)
{
//pointeur_station = int(Math.random() * liste_station.length);
pointeur_station = 0;
parametre_station = liste_station[pointeur_station];
lecture_information_station();
}
else if (liste_station[pointeur_station] != parametre_station && parametre_station.indexOf("http://", 0) == - 1)
{
lecteur.bouton_selection_station.visible = false;
arret_lecteur();
parametre_station = liste_station[pointeur_station];
lecture_information_station();
}
else lancer_lecteur("IDEM", null);
gestion_affichage_station();
}
private function action_bouton_stop(e:MouseEvent):void
{
arret_lecteur();
}
private function gestion_status_reseau(e:NetStatusEvent):void
{
switch (e.info.code)
{
case "NetConnection.Connect.Success" :
ouverture_flux_aac();
break;
case "NetConnection.Connect.Closed" :
break;
case "NetStream.Play.StreamNotFound" :
arret_lecteur();
break;
case "NetStream.Play.PublishNotify" :
break;
case "NetStream.Play.UnpublishNotify" :
arret_lecteur();
break;
case "NetStream.Play.Reset" :
break;
case "NetStream.Play.Start" :
break;
case "NetStream.Buffer.Full" :
timer_flux.start();
etat_marche = true;
status_connexion = "CONNECTE";
operation_en_cours = false;
recuperation_meta_donnee();
}
trace("- " + e.info.code);
}
private function erreur_asynchrone_reseau(e:AsyncErrorEvent):void
{
trace("- Erreur synchronisation !");
}
private function action_bouton_volume_up(e:MouseEvent):void {modification_volume = false;}
private function action_bouton_volume_down(e:MouseEvent):void {modification_volume = true;}
private function action_bouton_volume_move(e:MouseEvent):void
{
if (modification_volume && (e.stageX > 22) && (e.stageX < 106)) lecteur.bouton_volume.x = e.stageX;
}
private function action_bouton_station_plus(e:MouseEvent):void
{
if (liste_station.length == 0) return;
pointeur_station++;
if (pointeur_station >= liste_station.length) pointeur_station = 0;
gestion_affichage_station();
}
private function action_bouton_station_moins(e:MouseEvent):void
{
if (liste_station.length == 0) return;
pointeur_station--;
if (pointeur_station < 0) pointeur_station = liste_station.length - 1;
gestion_affichage_station();
}
private function action_bouton_flux(e:MouseEvent):void
{
if (operation_en_cours) return;
var test_flux:String = null;
var parametre_1:String;
var parametre_2:String;
var issue_de_secours:int = 0;
while (test_flux == null)
{
pointeur_flux++;
if (pointeur_flux > 3) pointeur_flux = 0;
switch (pointeur_flux)
{
case 0 :
test_flux = flux_mp3_haut;
parametre_1 = "H";
parametre_2 = "MP3";
break;
case 1 :
test_flux = flux_mp3_bas;
parametre_1 = "L";
parametre_2 = "MP3";
break;
case 2 :
test_flux = flux_rtmp_haut;
parametre_1 = "H";
parametre_2 = "AAC";
break;
case 3 :
test_flux = flux_rtmp_bas;
parametre_1 = "L";
parametre_2 = "AAC";
}
issue_de_secours++;
if (issue_de_secours > 5) return;
}
arret_lecteur();
lancer_lecteur(parametre_2, parametre_1);
}
private function action_bouton_selection_station(e:MouseEvent):void
{
lecteur.bouton_selection_station.visible = false;
arret_lecteur();
parametre_station = liste_station[pointeur_station];
lecture_information_station();
}
// Fenêtre de paramètrages
private function action_touche_enfoncee(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.ENTER)
{
trace(FENETRE_SAISIE.texte_saisie.text);
action_bouton_quitter_saisie(null);
arret_lecteur();
parametre_station = FENETRE_SAISIE.texte_saisie.text;
lecture_information_station();
}
}
private function action_bouton_saisie_flux(e:MouseEvent):void
{
addChild(FENETRE_SAISIE);
FENETRE_SAISIE.x = 25;
FENETRE_SAISIE.y = 7.5;
FENETRE_SAISIE.alpha = .85
FENETRE_SAISIE.bouton_quitter_saisie.addEventListener(MouseEvent.CLICK, action_bouton_quitter_saisie);
FENETRE_SAISIE.texte_saisie.addEventListener(MouseEvent.CLICK, action_commencer_saisie);
FENETRE_SAISIE.bouton_cache.addEventListener(MouseEvent.CLICK, action_bouton_cache);
FENETRE_SAISIE.bouton_proxy.addEventListener(MouseEvent.CLICK, action_bouton_proxy);
FENETRE_SAISIE.bouton_liste_1.addEventListener(MouseEvent.CLICK, action_bouton_liste_1);
FENETRE_SAISIE.bouton_liste_2.addEventListener(MouseEvent.CLICK, action_bouton_liste_2);
FENETRE_SAISIE.bouton_cache.buttonMode = true;
FENETRE_SAISIE.bouton_proxy.buttonMode = true;
FENETRE_SAISIE.bouton_liste_1.buttonMode = true;
FENETRE_SAISIE.bouton_liste_2.buttonMode = true;
action_bouton_cache(null);
action_bouton_proxy(null);
if (numero_liste == 1) action_bouton_liste_1(null);
else action_bouton_liste_2(null);
stage.addEventListener(KeyboardEvent.KEY_DOWN, action_touche_enfoncee);
}
private function action_bouton_quitter_saisie(e:MouseEvent):void
{
FENETRE_SAISIE.bouton_quitter_saisie.removeEventListener(MouseEvent.CLICK, action_bouton_quitter_saisie);
FENETRE_SAISIE.texte_saisie.removeEventListener(MouseEvent.CLICK, action_commencer_saisie);
FENETRE_SAISIE.bouton_cache.removeEventListener(MouseEvent.CLICK, action_bouton_cache);
FENETRE_SAISIE.bouton_proxy.removeEventListener(MouseEvent.CLICK, action_bouton_proxy);
FENETRE_SAISIE.bouton_liste_1.removeEventListener(MouseEvent.CLICK, action_bouton_liste_1);
FENETRE_SAISIE.bouton_liste_2.removeEventListener(MouseEvent.CLICK, action_bouton_liste_2);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, action_touche_enfoncee);
removeChild(this.FENETRE_SAISIE);
}
private function action_commencer_saisie(e:MouseEvent):void
{
if (!une_fois)
{
une_fois = true;
FENETRE_SAISIE.texte_saisie.text = "";
}
}
private function action_bouton_cache(e:MouseEvent):void
{
if (e != null) etat_cache = !etat_cache;
if (etat_cache) FENETRE_SAISIE.bouton_cache.alpha = 1;
else FENETRE_SAISIE.bouton_cache.alpha = .4;
}
private function action_bouton_proxy(e:MouseEvent):void
{
if (e != null) etat_proxy = !etat_proxy;
if (etat_proxy) FENETRE_SAISIE.bouton_proxy.alpha = 1;
else FENETRE_SAISIE.bouton_proxy.alpha = .4;
}
private function action_bouton_liste_1(e:MouseEvent):void
{
FENETRE_SAISIE.bouton_liste_1.alpha = 1;
FENETRE_SAISIE.bouton_liste_2.alpha = .4;
numero_liste = 1;
if (e != null) chargement_liste_xml(parametre_liste_1);
}
private function action_bouton_liste_2(e:MouseEvent):void
{
FENETRE_SAISIE.bouton_liste_1.alpha = .4;
FENETRE_SAISIE.bouton_liste_2.alpha = 1;
numero_liste = 2;
if (e != null) chargement_liste_xml(parametre_liste_2);
}
}
}
Conclusion
Quant à la programmation POO ... bof !
Vous pouvez me poser des questions !
Fichier Zip
Historique
- 08 novembre 2010 11:48:23 :
- Errata:
Les textes ACC ont été remplacés par AAC. ACC est l'accumulateur de µC MCS-51, et donc à ne pas confondre avec AAC (Advanced Audio Coding)
- 09 novembre 2010 07:38:26 :
- Passage du niveau expert, au niveau initié
- 17 novembre 2010 16:56:35 :
- Passage à la version V2.03
- 18 novembre 2010 10:51:10 :
- Modifications mineures
- 18 novembre 2010 11:05:05 :
- Errata et balise objet.
- 23 novembre 2010 10:41:49 :
- Version finale V2.05
Sources du même auteur
ERYPIANO V2.03 CS4 AS3ERYPIANO V2.03 CS4 AS3Le site ErySoft a été sujet à une attaque virale. J'ai rétabli ce dernier, mais Google mentionne et bloque toujours son accès, le temps de réexaminer ...
ERYSOKOBAN V1.02 CS4 AS3ERYSOKOBAN V1.02 CS4 AS3Tout le monde connait le célèbre jeu Sokoban ! Oui je sais, c'est un jeu pour vieux, sans fusils, bombes, lasers, et cibles à détruire, mais c'est trè...
ERYSKYPLAYER_MINIERYSKYPLAYER_MINIC'est la dernière source que je propose en AS3, pas vraiment orientée objet.
Comme la source précédente, ce lecteur permet de faire du crossdomain ...
ERYSKYVIDÉO V1.05 & V2.00ERYSKYVIDÉO V1.05 & V2.00Encore un lecteur flv !
Oui, mais celui-ci a l'avantage de pouvoir faire du streaming avec les fichiers flv que vous avez stockés sur Skydrive dans...
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Différence AS3 entre CS3 et CS4? [ par projer ]
Salut :) J'ai acheté un bouquin pour me mettre à l'AS3 mais je viens de m'appercevoir qu'il ne parle que de Flash CS3 et pas du tout de CS4... D'où
web radio et streaming [ par thtech ]
salut à tous ! j'ai besoin de votre aide. j'ai un web radio et je veut crier une application en flash permet de faire streaming à partir de mon serveu
Streaming radio en flash [ par alex1025 ]
Bonjour, Je voulais savoir si c'est possible de se connecter à une radio en flash ( exemple: http://www.radiofg.com/live/shoutcastFG.pls)
CS4/AS3 : [ par mouahaha ]
Bonjour à tous !Je me suis récemment mis à l'AS3, et à Flash CS4 (je regrette d'ailleurs de ne pas m'y être mis plus tôt ^^), et je m'y fais assez bie
Streaming [ par tatouer ]
Slt all,Voilà j'aimerai savoir s'il est possible de créer dans une interface, un genre de radio, avec plusieurs stations et de lire les radio en strea
bouton radio [ par zapeur4 ]
salut tout le mondejai des problemes evec la creationde bouton radioma question est la suivantecomment puis je creer les boutons radio sur flash 5?me
bouton radio [ par zapeur4 ]
bonjourbonjour tom merci d'avoir repondu a ma premiere questionj'ai essayer de te rpondre mais je me trouve sur cette pageet je suis forcer de te repo
vidéo et son en streaming [ par apprentie ]
Bonjour,Je voudrais savoir s'il existe un code et quel est ce code pour appeler une vidéo en streaming encodée pour realplayer, de même pour un extrai
comment faire une pause dans un mp3 en streaming ? [ par donutsboy ]
Es-ce que quelqu'un sais comment faire une pause dans une MP3 charger en streaming ?
Streaming MP3 pour les débutants [URGENT] [ par SonicK02 ]
voila je suis sous flash 5 (donc impossible de lire les sources sur ce site pour l'instant) et j'ai essayé pas mal de méthodes pour faire du streaming
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|