I am building a media player in as3 that can play videos and mp3s:
Latest version: (http://ronnieswietek.com/flashden/mp3player/version4.html)
My issue is that the mp3s nor the videos play until they are fully loaded. I’ve set buffer times for each yet to no avail they still wont play til fully loaded. Can anyone see why? The top half deals with the MP3s while the bottom half deal with the FLVs.
//Video
var v:FLVPlayback = new FLVPlayback();
//Sound
var s:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
var context:SoundLoaderContext = new SoundLoaderContext(2000, false);
switch (data_ar[itemID].type)
{
case "mp3" :
currentType = "mp3";
checkMediaHolders();
btn1.txt.text = audioControlLabels[4];
notPlaying = false;
var thumbReq:URLRequest = new URLRequest(data_ar[itemID].thumb);
var thumbLoader:Loader = new Loader();
thumbLoader.load(thumbReq);
mediaPlayer.thumbHolder.addChild(thumbLoader);
var urlReq:URLRequest = new URLRequest(data_ar[itemID].source);
var ldr:URLLoader = new URLLoader(urlReq);
s = new Sound();
s.load(urlReq, context);
tmrDisplay = new Timer(displayDelay);
tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);
s.addEventListener(Event.COMPLETE, beginTimer);
ldr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
soundControl.stop();
soundControl = s.play(0, 1, new SoundTransform(vol, 0));
soundControl.addEventListener(Event.SOUND_COMPLETE, playNext);
break;
case "flv" :
currentType = "flv";
soundControl.stop();
checkMediaHolders();
btn1.txt.text = audioControlLabels[4];
notPlaying = false;
v = new FLVPlayback();
v.width = 200;
v.height = 133;
v.bufferTime = 5;
var vidLoader:URLLoader = new URLLoader(new URLRequest(data_ar[itemID].source));
vidLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
v.addEventListener(MetadataEvent.METADATA_RECEIVED, metaDataHandler);
v.addEventListener(VideoEvent.COMPLETE, playNext);
mediaPlayer.vidHolder.addChild(v);
v.play(data_ar[itemID].source);
break;
}