reproductor mp3 en flash (volumen)
Hoy viene la tercera parte para crear un reproductor en flash completo. Ahora añadiremos al codigo anterior las opciones de volumen.
Este es el codigo:
- function cargar_mp3(mp3) {
- //creamos una instancia de sonido
- cancion = new Sound();
- cancion.setVolume(volumen_cancion);
- volumen.text = cancion.getVolume();
- //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”;
- };
- //llamamos a la funcion para cargar el mp3
- volumen_cancion = 100;
- cargar_mp3(”http://www.forosdeflash.com/blog/wp-content/cancion.mp3
- b_pause.onRelease = function() {
- ultimaPosicion = Math.round(cancion.position/1000);
- cancion.stop();
- };
- b_stop.onRelease = function() {
- ultimaPosicion = 0;
- cancion.stop();
- };
- b_play.onRelease = function() {
- if (ultimaPosicion == 0) {
- cancion.start();
- } else {
- cancion.start(ultimaPosicion);
- }
- };
- vmas.onRelease = function() {
- if (volumen_cancion == 100) {
- } else {
- volumen_cancion += 5;
- cancion.setVolume(volumen_cancion);
- volumen.text = cancion.getVolume();
- }
- };
- vmenos.onRelease = function() {
- if (volumen_cancion == 0) {
- } else {
- volumen_cancion -= 5;
- cancion.setVolume(volumen_cancion);
- volumen.text = cancion.getVolume();
- }
- };
Ejemplo:
This movie requires Flash Player 8
7 comments February 8th, 2007
