Olá pessoal,
minha dúvida é bem simples tenho um player de MP3 e gostaria de exibir o bitrate da musisca é possivel? se sim como?
valew pessoal ...
Exibir O Bitrate
Started By bdoweb, 14/11/2006, 08:44
2 replies to this topic
#1
Posted 14/11/2006, 08:44
Quer ajuda seus amigo e ainda ganhar uma graninha?
Acesse agora mesmo http://yeapiz.com
Acesse agora mesmo http://yeapiz.com
#2
Posted 24/11/2006, 08:19
No Flash 8 (AS 1/2.0) não tem como ser feito a não ser que você pegue o tamanho do arquivo, tempo do som e tralalas e calcule manualmente o bitrate, acho que assim é possivel mas posso estar muito errado sobre isso 
Já com AS3 e Flash 9 é possivel... aqui uma classe de um MP3 Player em Flash 9
Já com AS3 e Flash 9 é possivel... aqui uma classe de um MP3 Player em Flash 9
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.media.ID3Info;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.Timer;
import mx.core.IMXMLObject;
[Event(name="close", type="flash.events.Event")]
[Event(name="complete", type="flash.events.Event")]
[Event(name="id3", type="flash.events.Event")]
[Event(name="ioError", type="flash.events.IOErrorEvent")]
[Event(name="open", type="flash.events.Event")]
[Event(name="play", type="flash.events.Event")]
[Event(name="progress", type="flash.events.ProgressEvent")]
[Event(name="soundComplete", type="flash.events.Event")]
[Event(name="soundProgress", type="flash.events.Event")]
[Event(name="stop", type="flash.events.Event")]
public class SoundPlayer extends EventDispatcher implements IMXMLObject
{
private static const POSITION_UPDATE_INTERVAL:Number = 100;
private var _initialized:Boolean;
private var sound:Sound;
private var soundChannel:SoundChannel;
private var lastPosition:Number = 0;
private var positionUpdateTimer:Timer;
private var inPause:Boolean;
public function SoundPlayer()
{
}
private var _autoPlay:Boolean = true;
public function get autoPlay():Boolean
{
return _autoPlay;
}
public function set autoPlay(value:Boolean):void
{
_autoPlay = value;
}
private var _autoLoad:Boolean = true;
public function get autoLoad():Boolean
{
return _autoLoad;
}
public function set autoLoad(value:Boolean):void
{
_autoLoad = value;
}
[Bindable("close")]
[Bindable("complete")]
[Bindable("open")]
[Bindable("progress")]
public function get bytesLoaded():uint
{
return sound ? sound.bytesLoaded : 0;
}
[Bindable("close")]
[Bindable("complete")]
[Bindable("open")]
[Bindable("progress")]
public function get bytesTotal():int
{
return sound ? sound.bytesTotal : -1;
}
[Bindable("close")]
[Bindable("id3")]
public function get id3():ID3Info
{
return sound ? sound.id3 : null;
}
[Bindable("close")]
[Bindable("complete")]
[Bindable("open")]
[Bindable("progress")]
public function get isBuffering():Boolean
{
return sound ? sound.isBuffering : false;
}
[Bindable("play")]
[Bindable("stop")]
public function get isPlaying():Boolean
{
return soundChannel != null;
}
[Bindable("close")]
[Bindable("complete")]
public function get length():Number
{
return sound ? sound.length : NaN;
}
[Bindable("soundComplete")]
[Bindable("soundProgress")]
[Bindable("stop")]
public function get position():Number
{
return soundChannel ? soundChannel.position : lastPosition;
}
public function set position(value:Number):void
{
if (position != value && isPlaying)
{
// seek to new position
pause();
lastPosition = value;
play();
}
}
private var _source:String;
public function get source():String
{
return _source;
}
public function set source(value:String):void
{
if (source != value)
{
_source = value;
stop();
close();
if (autoPlay)
play();
else if (autoLoad)
load();
}
}
[Bindable("close")]
[Bindable("open")]
public function get url():String
{
return sound ? sound.url : null;
}
private var _volume:Number = 0.75;
[Bindable("volumeChanged")]
public function get volume():Number
{
return _volume;
}
public function set volume(value:Number):void
{
if (volume != value)
{
_volume = value;
if (soundChannel)
soundChannel.soundTransform = new SoundTransform(volume);
dispatchEvent(new Event("volumeChanged"));
}
}
public function initialized(document:Object, id:String):void
{
if (autoPlay)
play();
else if (autoLoad)
load();
_initialized = true;
}
public function load():void
{
if (!source)
return;
if (sound)
// already loaded
return;
sound = new Sound();
sound.addEventListener("complete", bounceEvent);
sound.addEventListener("id3", bounceEvent);
sound.addEventListener("ioError", bounceEvent);
sound.addEventListener("open", bounceEvent);
sound.addEventListener("progress", bounceEvent);
sound.load(new URLRequest(source));
}
public function play():void
{
if (!source)
return;
if (soundChannel)
// already playing
return;
load();
soundChannel = sound.play(lastPosition);
soundChannel.soundTransform = new SoundTransform(volume);
positionUpdateTimer = new Timer(POSITION_UPDATE_INTERVAL);
positionUpdateTimer.addEventListener("timer", updatePosition);
positionUpdateTimer.start();
dispatchEvent(new Event("play"));
soundChannel.addEventListener("soundComplete", bounceEvent);
}
public function pause():void
{
inPause = true;
stop();
inPause = false;
}
public function stop():void
{
if (!soundChannel)
return;
soundChannel.stop();
positionUpdateTimer.stop();
positionUpdateTimer = null;
if (!inPause)
lastPosition = 0;
soundChannel.removeEventListener("soundComplete", bounceEvent);
soundChannel = null;
dispatchEvent(new Event("stop"));
}
public function close():void
{
if (!sound)
return;
if (bytesLoaded < bytesTotal)
sound.close();
sound.removeEventListener("complete", bounceEvent);
sound.removeEventListener("id3", bounceEvent);
sound.removeEventListener("ioError", bounceEvent);
sound.removeEventListener("open", bounceEvent);
sound.removeEventListener("progress", bounceEvent);
sound = null;
dispatchEvent(new Event("close"));
}
private function bounceEvent(event:Event):void
{
var cloneEvent:Event = event.clone();
dispatchEvent(cloneEvent);
if (cloneEvent.type == "soundComplete")
stop();
}
private function updatePosition(event:Event):void
{
if (!isNaN(position) && lastPosition != position)
{
lastPosition = position;
dispatchEvent(new Event("soundProgress"));
}
}
}
}
[]'s
Michel
Michel
#3
Posted 24/11/2006, 09:15
nossa cara que código assustador
...
Então de flash naum manjo muito essas paradas de classes ... mas eu posso importar essa classe neh ???
E pelo q vi dessa classe ela é um player neh ?
Então de flash naum manjo muito essas paradas de classes ... mas eu posso importar essa classe neh ???
E pelo q vi dessa classe ela é um player neh ?
Quer ajuda seus amigo e ainda ganhar uma graninha?
Acesse agora mesmo http://yeapiz.com
Acesse agora mesmo http://yeapiz.com
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)










