Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
amnporter

Loading FLVs from a different server using Loadermax

Recommended Posts

I've come across and issue which I have found a work around. I am loading and playing external FLVs from a different server from where my SWF is located. When published locally and pulling in the FLVs, everything worked fine. When placing the SWF online, it wouldn't load the FLVs. After a day of troubleshooting and using crossdomain policies, I've narrowed it down to the loading procedure used. My findings are below. Please feel free to comment or let me know if I missed something that would have prevented me from wasting a day.

 

I have done the following:

1. added crossdomain.xml to the site where the FLVs reside

2. added

import flash.system.Security;
Security.loadPolicyFile("http://www.mywebsite.com/crossdomain.xml");
<br><br>

to my FLA

The above files/code didn't have an impact on anything after my testing.

 

I was loading the videos through the following code:

var numVids = this.model.xml.q.opt.length();
for (var k:Number = 1; k <= numVids; k++) {

 var videoSrc:String = vidPath + this.model.xml.q.opt[(k - 1)].source;
 urls.push(videoSrc);

 var videoSrcFB:String = vidPath + this.model.xml.q.opt[(k - 1)].fb.source;
 urls.push(videoSrcFB);
}
//trace ("urls = " + urls);
var queue:LoaderMax = LoaderMax.parse(urls, { onProgress:_progressHandler, onComplete:_queueComplete, onChildComplete:_childComplete }, { width:873.6, height:479, autoPlay:false } );

queue.load();

The above code worked fine when publishing the SWF and testing locally but wouldn't load the FLVs once I placed it online.

 

My workaround:

 

var numVids = this.model.xml.q.opt.length();
for (var k:Number = 1; k <= numVids; k++) {

 var videoSrc:String = vidPath + this.model.xml.q.opt[(k - 1)].source;
 urls.push(videoSrc);

 var videoSrcFB:String = vidPath + this.model.xml.q.opt[(k - 1)].fb.source;
 urls.push(videoSrcFB);
}
//trace ("urls = " + urls);
var queue:LoaderMax = LoaderMax.parse(urls, { onProgress:_progressHandler, onComplete:_queueComplete, onChildComplete:_childComplete }, { width:873.6, height:479, autoPlay:false } );


for (var m:Number = 1; m <= urls.length; m++) {
 //append several loaders
 var load = urls[(m - 1)];
 var video:VideoLoader = new VideoLoader(load, { onComplete:_queueComplete, width:873.6,	height:479, autoPlay:false } );  //<--THIS IS THE CODE THAT WORKED
 video.load();
}

 

I would much rather keep the LoaderMax.parse function to keep the code nice and clean but doesn't seem to do the trick when trying to play FLVs from diff server. Has anyone run into similar issues?

Link to comment
Share on other sites

If you want the LoaderMax.parse() method to be able to recognize specific loader types based on the file extension, you need to activate() the associated loader types first, like:

 

LoaderMax.activate([VideoLoader, ImageLoader]);

 

Does that solve the problem for you?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×