Cosmo1119
04-30-2007, 01:57 PM
Hi everyone,
I'm building a client server appliction using flash: the client app is a projector that connects to a server and loads some sfw files from that server. One of these files is used to play videos...
When I test this file locally it works: I run it on my computer and it fetches the videos on the server.
The problem occurs when I load it through the projector; the projector is run from my computer, it then loads the mentionned swf from the server which in turn loads the videos from the server. So the swf and the videos both come from the server...
I did a little debugging and I think it has something to do with the netconnection not being setup properly:
this.m_oConnection_nc.connect(null);
seems to be at fault and I'm wondering if I should put the domain name as an argument...
Basically the _videoStatus function never gets callled so i assume the NetStream object is not instaciated...
This is the class used by the swf that plays the video:
import mx.utils.Delegate;
import mx.Video.*;
class FLVPlayer
{
var m_oConnection_nc:NetConnection;
var m_oStream_ns:NetStream;
var m_aPlaylist:Array;
var m_oXMLData:XML;
var m_sLastUpdate:String;
var m_nBufferTime:Number;
var m_sNowPlaying:String;
var m_sProgram:String;
var m_sRootFolder:String;
var m_aLangues:Array;
var m_aCat:Array;
var m_aCatDuration:Array;
var m_nLangInterval:Number;
function FLVPlayer(Void)
{
m_aCat= new Array();
m_aCatDuration= new Array();
m_aLangues=new Array("Francais", "Anglais");
//create video player
this.m_nBufferTime=3;
this.m_oConnection_nc= new NetConnection();
this.m_oConnection_nc.connect(null);
this.m_oStream_ns = new NetStream(this.m_oConnection_nc);
this.m_oStream_ns.setBufferTime(this.m_nBufferTime );
this.m_oStream_ns.onStatus =Delegate.create(this, _videoStatus);
_root.Video_1.attachVideo(this.m_oStream_ns);
m_sLastUpdate="0000";
m_aPlaylist=new Array();
m_oXMLData= new XML();
m_oXMLData.ignoreWhite=true;
this.m_oXMLData.onLoad=Delegate.create(this, _onLoadXML);
if(_root.s_ConnectionType.toUpperCase() == "LOCAL"){
this.m_oXMLData.load("playlist.xml");
}
else{
var m_LoadVars:LoadVars=new LoadVars();
m_LoadVars.idEtablissement=_root.n_idEtablissement ;
m_LoadVars.idElement=_root.n_idElement;
m_LoadVars.sendAndLoad(_root.s_Server+"client/GetPlaylist.php", this.m_oXMLData,"GET");
}
}
function _onLoadXML(success:Boolean):Void
{
if(success){
_root.debug_txt.text+="DEBUG: SUCCESS LOADING XML FROM SERVER";
this.m_sLastUpdate=this.m_oXMLData.firstChild.attr ibutes.last_upd;
this.m_sRootFolder=this.m_oXMLData.firstChild.attr ibutes.root_folder;
var xml_nodes:Array=this.m_oXMLData.firstChild.childNo des;
for(var i:Number=0; i< xml_nodes.length; i++)
{
var CurEntry:Object =new VideoEntry();
CurEntry.m_sFileName=xml_nodes[i].attributes.video_file;
CurEntry.m_sCategory=xml_nodes[i].attributes.video_category;
CurEntry.m_sLanguage=xml_nodes[i].attributes.video_language;
CurEntry.m_sId=xml_nodes[i].attributes.video_id;
CurEntry.m_nDuration=Number(xml_nodes[i].attributes.video_length);
this.m_aPlaylist.push(CurEntry);
}
_root.debug_txt.text+="DEBUG: ATTEMPTING TO PLAY VIDEO\n";
PlayNextVideo();
m_nLangInterval=setInterval(SwitchLanguage, 5000, this);
}
else{
_root.debug_txt.text+="DEBUG: ***ERROR*** LOADING XML FROM SERVER";
}
}
function PlayNextVideo(Void):Void{
var mVideoFile:String;
if(_root.s_ConnectionType.toUpperCase() == "LOCAL"){
mVideoFile=this.m_aPlaylist[0].m_sFileName;
}
else{
mVideoFile=_root.s_Server+this.m_sRootFolder+this. m_aPlaylist[0].m_sId+"/"+this.m_aPlaylist
[0].m_sFileName;
}
this.m_oStream_ns.play(mVideoFile);
_root.debug_txt.text+="VIDEO PLAYING:::"+mVideoFile+"\n";
trace ("Load next movie "+m_aPlaylist[0].m_sFileName);
//get nex video to play
this.m_aPlaylist.push(this.m_aPlaylist.shift());
}
function SwitchLanguage(obj:Object):Void{
obj.m_aLangues.push(obj.m_aLangues.shift());
obj.ShowProgram(obj);
}
function _videoStatus(infoObject:Object) {
//trace("NetStream.onStatus called: ("+getTimer()+" ms)");
if (infoObject.code == "NetStream.Play.StreamNotFound") {
PlayNextVideo();
}
if (infoObject.code == "NetStream.Play.Stop") {
PlayNextVideo();
}
_root.debug_txt.text+="code= "+infoObject.code+"\n";
// trace("code= "+infoObject.code);
}
}
any ideas???
I'm building a client server appliction using flash: the client app is a projector that connects to a server and loads some sfw files from that server. One of these files is used to play videos...
When I test this file locally it works: I run it on my computer and it fetches the videos on the server.
The problem occurs when I load it through the projector; the projector is run from my computer, it then loads the mentionned swf from the server which in turn loads the videos from the server. So the swf and the videos both come from the server...
I did a little debugging and I think it has something to do with the netconnection not being setup properly:
this.m_oConnection_nc.connect(null);
seems to be at fault and I'm wondering if I should put the domain name as an argument...
Basically the _videoStatus function never gets callled so i assume the NetStream object is not instaciated...
This is the class used by the swf that plays the video:
import mx.utils.Delegate;
import mx.Video.*;
class FLVPlayer
{
var m_oConnection_nc:NetConnection;
var m_oStream_ns:NetStream;
var m_aPlaylist:Array;
var m_oXMLData:XML;
var m_sLastUpdate:String;
var m_nBufferTime:Number;
var m_sNowPlaying:String;
var m_sProgram:String;
var m_sRootFolder:String;
var m_aLangues:Array;
var m_aCat:Array;
var m_aCatDuration:Array;
var m_nLangInterval:Number;
function FLVPlayer(Void)
{
m_aCat= new Array();
m_aCatDuration= new Array();
m_aLangues=new Array("Francais", "Anglais");
//create video player
this.m_nBufferTime=3;
this.m_oConnection_nc= new NetConnection();
this.m_oConnection_nc.connect(null);
this.m_oStream_ns = new NetStream(this.m_oConnection_nc);
this.m_oStream_ns.setBufferTime(this.m_nBufferTime );
this.m_oStream_ns.onStatus =Delegate.create(this, _videoStatus);
_root.Video_1.attachVideo(this.m_oStream_ns);
m_sLastUpdate="0000";
m_aPlaylist=new Array();
m_oXMLData= new XML();
m_oXMLData.ignoreWhite=true;
this.m_oXMLData.onLoad=Delegate.create(this, _onLoadXML);
if(_root.s_ConnectionType.toUpperCase() == "LOCAL"){
this.m_oXMLData.load("playlist.xml");
}
else{
var m_LoadVars:LoadVars=new LoadVars();
m_LoadVars.idEtablissement=_root.n_idEtablissement ;
m_LoadVars.idElement=_root.n_idElement;
m_LoadVars.sendAndLoad(_root.s_Server+"client/GetPlaylist.php", this.m_oXMLData,"GET");
}
}
function _onLoadXML(success:Boolean):Void
{
if(success){
_root.debug_txt.text+="DEBUG: SUCCESS LOADING XML FROM SERVER";
this.m_sLastUpdate=this.m_oXMLData.firstChild.attr ibutes.last_upd;
this.m_sRootFolder=this.m_oXMLData.firstChild.attr ibutes.root_folder;
var xml_nodes:Array=this.m_oXMLData.firstChild.childNo des;
for(var i:Number=0; i< xml_nodes.length; i++)
{
var CurEntry:Object =new VideoEntry();
CurEntry.m_sFileName=xml_nodes[i].attributes.video_file;
CurEntry.m_sCategory=xml_nodes[i].attributes.video_category;
CurEntry.m_sLanguage=xml_nodes[i].attributes.video_language;
CurEntry.m_sId=xml_nodes[i].attributes.video_id;
CurEntry.m_nDuration=Number(xml_nodes[i].attributes.video_length);
this.m_aPlaylist.push(CurEntry);
}
_root.debug_txt.text+="DEBUG: ATTEMPTING TO PLAY VIDEO\n";
PlayNextVideo();
m_nLangInterval=setInterval(SwitchLanguage, 5000, this);
}
else{
_root.debug_txt.text+="DEBUG: ***ERROR*** LOADING XML FROM SERVER";
}
}
function PlayNextVideo(Void):Void{
var mVideoFile:String;
if(_root.s_ConnectionType.toUpperCase() == "LOCAL"){
mVideoFile=this.m_aPlaylist[0].m_sFileName;
}
else{
mVideoFile=_root.s_Server+this.m_sRootFolder+this. m_aPlaylist[0].m_sId+"/"+this.m_aPlaylist
[0].m_sFileName;
}
this.m_oStream_ns.play(mVideoFile);
_root.debug_txt.text+="VIDEO PLAYING:::"+mVideoFile+"\n";
trace ("Load next movie "+m_aPlaylist[0].m_sFileName);
//get nex video to play
this.m_aPlaylist.push(this.m_aPlaylist.shift());
}
function SwitchLanguage(obj:Object):Void{
obj.m_aLangues.push(obj.m_aLangues.shift());
obj.ShowProgram(obj);
}
function _videoStatus(infoObject:Object) {
//trace("NetStream.onStatus called: ("+getTimer()+" ms)");
if (infoObject.code == "NetStream.Play.StreamNotFound") {
PlayNextVideo();
}
if (infoObject.code == "NetStream.Play.Stop") {
PlayNextVideo();
}
_root.debug_txt.text+="code= "+infoObject.code+"\n";
// trace("code= "+infoObject.code);
}
}
any ideas???