A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Sound stream from external URL cross domain policy issue

  1. #1
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971

    resolved [RESOLVED] Sound stream from external URL cross domain policy issue

    Hi guys,

    I have this on my flash
    PHP Code:
    var stream1:Sound = new Sound();
    stream1.load(new URLRequest("http://ipaddress:port/"));
    Security.allowDomain("*");
    Security.allowInsecureDomain("*");
    Security.loadPolicyFile("http://mysite.com/crossdomain.xml");
    stream1.play(); 
    It works perfectly locally.
    When i upload it in my IIS server, or in my hosting server, the sound doesn't play.

    I created a cross domain policy *.xml file in my server's root folder with this:
    PHP Code:
    <cross-domain-policy 
    xmlns
    :xsi="http://mySite.com"
    xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
     <
    allow-access-from domain="streamSiteIpAddress:sitePort"/>
     <
    allow-access-from domain="streamSiteIpAdress"/>
    <
    allow-access-from domain="*" secure="false" to-ports="*">
    </
    cross-domain-policy
    No success. Thanks
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Are you trying to do advanced stuff or just figure out the cross domain xml?

    The cross domain policy is to declare access and control access to your xml only (as far as I know). It's so you can't simply put something on a.com that loads an xml from b.com.

    The Security. stuff shouldn't be in your flash. It should be in your embed code. You should just learn what they do but you don't use them usually. It usually about playing swf's from b.com on a.com's site - http://www.b.com/example.swf is the reference vs. example.swf so the swf is crossing domains. Plus you have settings in embed code to control what the swf can do on your site. For example, can the outside swf access your javascript which is a security issue.

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Thanks for replying! And well, i see. But what I want to do is, to load a sound that is being streaming at an IP address (radio). It plays perfectly if i publish the site in flash, but when I run it on my IIS server, or on my ********** server, no sound. I get a" Adobe Flash Player has stopped a potentially unsafe operation." error when Testing the movie in HTML.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Try it with no security settings.

    Since the swf is clientside, like html, if you use a full reference "http://www..." for the files, you're not loading the file across servers. The user is loading the files. The user loads your html, your swf, and your swf tells the user to load whatever sound file from wherever. You know how you can put jpgs from other servers on your html page?

    You should be able to load everything directly into browser. Put the url in the address and file will either play or prompt for download. For example: http://www.a.com/myRadio.swf, http://www.a.com/myXML.xml, http://www.b.com/myAudio.mp3 should all play or download in browser for the three to work together as a player.

    The security settings are there if you want to allow somebody else's swf to do whatever it wants.
    Last edited by moot; 01-20-2014 at 12:37 PM.

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Make one small adjustment to your address, I know it's shoutcast radio.
    PHP Code:
    import flash.media.Sound;
    import flash.media.SoundChannel;

    import flash.net.URLRequest;

    var 
    Stream1:Sound = new Sound();
    var 
    StreamChannel1:SoundChannel = new SoundChannel();
    Stream1.load(new URLRequest("http://72.13.86.83:80/;"));
    StreamChannel1 Stream1.play(); 
    Notice the semi colon at the end of the address, it willl now work.
    As far as I have tested it only need be done to shoutcast urls.

    This will work within flash and embedded in your html page.

    To make it work as on a standalone swf or exe, go to publish settings and local playback security(at bottom) set to access network.

    No need for the system.security stuff as stated by other people.
    Last edited by fruitbeard; 01-20-2014 at 01:19 PM.

  6. #6
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Thanks you very much moot. I know your tips will be very useful.

    Fruitbeard, you are sooo funny and amazing hehe

    Did you decompiled my swf, or checked up the crossdomain.xml ? Hehe.

    Anyway, i have not tested the semi colon thing, but I know with my eyes closed, that it will work because you are a PRO.

    Thanks
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Here's a small AS3 radio streamer with added extras for you to play around with, it works as a standalone player also.

  8. #8
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Thank you very much Fruitbeard. I already know the process to store differents URL's/song in an XML, and stream it in flash, and shuffle it, repeat, rewind, FF, mute, pause, etc. But i will check your files, maybe I learn something new, one always learn something new each day hehe.

    Take care buddy
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center