Question

I have a SWF loaded via a "swfobject.embedSWF()"

I use Javascript's methods to pass calls via the flash APIs: http://developer.longtailvideo.com/trac/wiki/Player4Api#Sendingevents

call.player.sendEvent('LOAD', theFile)

Using a XMLHttpRequest() call via GET to a PHP script I get a file url:

http://xx.yy.com/protected/5dde98716ad8f31127ab560d94f96b87/4cbabea0/test.mp4

Typing the URL into my browser starts the file, but passing the variable to the sendEvent() call does nothing. Why?

var response = http.responseText;    
loadFile(response);
player.sendEvent('PLAY');

Is there something obvious that I am doing wrong? :/

Thanks.

EDIT1: Solution

I have gotten the generated url to load and play correctly by not just returning the video url with the XMLHttpRequest() but returning an actual xml file with the necessary parameters to work with some of the modules I am using.

<rss version="2.0" 
    xmlns:media="http://search.yahoo.com/mrss/" 
    xmlns:jwplayer="http://developer.longtailvideo.com/trac/wiki/FlashFormats">
    <channel>
        <title>Example media RSS playlist</title>
        <item>
            <title>Lighttpd Video</title>
            <media:content url="http://xx.yy.com/protected/91aa7dfa25596a7d59c3b9403fc4773f/4cbb35d6/test.mp4" />
            <jwplayer:provider>http</jwplayer:provider>
            <jwplayer:http.startparam>start</jwplayer:http.startparam>
        </item>
    </channel>
</rss>

I wonder if this is as obvious as it seems now. Can XMLHTTPRequest() only return responses formatted as xml files? :/

Was it helpful?

Solution

The file is not being loaded probably because is cross-domain restrictions in flash.

I'm assuming that the domain from where flash swf is being loaded is not same the domain from where the audio file is being loaded.

To override this restriction you need a crossdomain.xml file placed at the root directory of the server where your sound file is hosted.

<?xml version="1.0"?>
<!-- http://www.youtube.com/crossdomain.xml -->
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

this file should be placed at the root directory of your web server, ie, http://xx.yy.com/crossdomain.xml

OTHER TIPS

In AS3 , you have to use the Sound class in order to play a sound. Your sound instance will need to load the URL , via a URLRequest object , in order for the sound to be played.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top