Función para cargar mp3 con actionscript en streaming
January 29th, 2007
Aquí empiezo una serie de tutoriales para trabajar con archivos mp3. Paso a paso iremos creando un reproductor completo mp3 en flash. La primera entrega crearemos una función para cargar un mp3 en streaming.
Este es el codigo:
- function cargar_mp3(mp3) {
- //creamos una instancia de sonido
- cancion = new Sound();
- //cargamos el mp3 y ponemos la variable de inStreaming en true
- cancion.loadSound(mp3, true);
- //Iniciamos onEnterFrame para visualizar la precarga del archivo mp3
- this.onEnterFrame = function() {
- BytesLoaded = cancion.getBytesLoaded();
- BytesTotal = cancion.getBytesTotal();
- porcentaje = Math.floor(BytesLoaded/BytesTotal*100);
- if (!isNaN(porcentaje)) {
- estado.text = porcentaje+”% cargado.”;
- }
- };
- //en cuanto el mp3 este totalmente cargamos eliminamos onEnterFrame
- cancion.onLoad = function() {
- delete onEnterFrame;
- estado.text = “carga completa”;
- };
- }
- //Al clicar encima del boton llamamos a la funcion para cargar el mp3
- boton.onRelease = function() {
- cargar_mp3(”http://www.forosdeflash.com/blog/wp-content/cancion.mp3″);
- };
Ejemplo:
This movie requires Flash Player 8
Entry Filed under: ActionScript
5 Comments Add your own
1. redouane | June 7th, 2007 at 20:21
DNF
2. roberto | August 13th, 2007 at 16:02
muy pare y no se cargo
3. nicolas | August 14th, 2007 at 5:29
muchas gracias! funciona a la perfección
le estare eternamente agradecido.
4. brahim el mir | October 27th, 2007 at 12:17
vui cargar mi mp3 i nose fe
5. Daverod | December 20th, 2007 at 9:51
Como puedo hacer para que se repita en cuanto termine la cancion? claro sin necesidad del boton… es posible?
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed