Hey guys,
i’m having problems with my xml FLVplayer.
at this link http://thuis.diamond4it.nl/xml/playerCS3.html can you see my player.
Problem1:
problem fixed, still one to go.
Problem2:
If you’re watching a movie and you start a new one, they keep on playing. Does someone know how to stop this?
import fl.data.DataProvider;
var xmlLoader:URLLoader = new URLLoader();
var xmlRequest:URLRequest = new URLRequest("playlist.xml");
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
xmlLoader.load(xmlRequest);
var i:int = 0;
var soundStatus:int;
var vidLoaded:Boolean = false;
var currentVid:int;
var vidXml:XML = new XML();
var vidList:XMLList;
var vidDpd:DataProvider;
var vidUrl:Array = new Array();
var vidString:String;
var vidDesc:Array = new Array();
var vidConnection:NetConnection = new NetConnection();
var vidStream:NetStream;
var vidObj:Video;
soundStatus = 0;
navMenu.visible = false;
navMenu.playBtn.buttonMode = true;
navMenu.stopBtn.buttonMode = true;
navMenu.pauseBtn.buttonMode = true;
navMenu.fullBtn.buttonMode = true;
navMenu.muteBtn.buttonMode = true;
navMenu.playBtn.addEventListener(MouseEvent.CLICK, playVid);
navMenu.stopBtn.addEventListener(MouseEvent.CLICK, stopVid);
navMenu.pauseBtn.addEventListener(MouseEvent.CLICK, pauseVid);
navMenu.fullBtn.addEventListener(MouseEvent.CLICK, fullVid);
navMenu.muteBtn.addEventListener(MouseEvent.CLICK, muteVid);
vidConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
vidConnection.connect(null);
function netStatusHandler(evt:NetStatusEvent):void
{
if(evt.info.code == "NetConnection.Connect.Failed")
{
trace("Connection Failed");
}
else if(evt.info.code == "NetStream.Play.Stop")
{
completeVid();
}
}
function aSyncErrorHandler(evt:AsyncErrorEvent):void
{
//trace niks
}
function xmlLoaded(evt:Event):void
{
vidXml = XML(xmlLoader.data);
vidList = new XMLList(vidXml.vid)
for(i = 0; i < vidList.length(); i++)
{
vidUrl.push(vidList*.url);
vidDesc.push(vidList*.desc.toString());
}
vidDpd = new DataProvider(vidDesc);
uiList.dataProvider = vidDpd;
}
uiList.addEventListener(Event.CHANGE, selectVid);
function selectVid(evt:Event):void
{
currentVid = evt.target.selectedIndex;
vidString = vidXml.vid[currentVid].url;
vidStream = new NetStream(vidConnection);
vidStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
vidStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, aSyncErrorHandler);
vidObj = new Video(245,183);
vidObj.smoothing = true;
vidObj.attachNetStream(vidStream);
if(!vidLoaded){
vidStream.play(vidString,0,-1,true);
addChild(vidObj);
navMenu.visible = true;
vidLoaded = true;
}else{
vidStream.resume();
}
}
function completeVid():void
{
vidStream.close();
vidObj.clear();
}
function playVid(evt:MouseEvent):void
{
if(!vidLoaded){
vidStream.play(vidString,0,-1,true);
addChild(vidObj);
navMenu.visible = true;
vidLoaded = true;
}else{
vidStream.resume();
}
}
function stopVid(evt:MouseEvent):void
{
vidStream.pause();
vidStream.seek(0);
vidLoaded = false;
}
function pauseVid(evt:MouseEvent):void
{
vidStream.pause();
}
function muteVid(evt:MouseEvent):void
{
if(soundStatus == 0)
{
var soundForm:SoundTransform = new SoundTransform(0);
vidStream.soundTransform = soundForm;
soundStatus = 1;
}else if(soundStatus == 1)
{
soundForm = new SoundTransform(1);
vidStream.soundTransform = soundForm;
soundStatus = 0;
}
}
function fullVid(evt:MouseEvent):void
{
trace("sjaak");
}
Thanks alot!
Rob