Using crossdomain.xml for subtitles and playlists

crossdomain policySubtitle files and playlists are supposed to reside on your domain due to security restrictions of Flash.  When you upload such files on an external location, be it another domain or a S3 bucket, access it denied when you link to them and no error is given in the Flash player. But there is a solution, namely a crossdomain policy!

For example: Let’s say you uploaded myvideo.mp4 and subtitles-myvideo.xml to a bucket with a CloudFront distribution.
You are using the S3Media Stream plugin and you simply fill in the information in the Video Wizard and do a test.  The video plays nicely, but you have no subtitles!
Yet, you uploaded both the video and xml file to the same bucket with a CloudFront distribution, like http://gfngnb51f.cloudfront.net
How to fix that?

You make it work by uploading a crossdomain.xml to your CloudFront distribution, in this case, you upload it to the bucket that contains the http://gfngnb51f.cloudfront.net distribution. But first you have to create that crossdomain.xml file, of course.
Do not panic, it is dead easy!

Making your own crossdomain.xml policy

Let’s presume you want to play the video on your blog called mystory.com.  In this example, we have a standard policy that we only need to adapt to our circumstance. Copy the green code below and paste it into a text file created with Notepad (Windows) or Simple Text(Mac).  Make sure you do not use a text editor that can format text, otherwise the file will not be saved correctly.  Save it as crossdomain.xml.

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.adobe.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<site-control permitted-cross-domain-policies=”master-only”/>
<allow-access-from domain=”*.wp21century.com“/>
</cross-domain-policy>

Now, you only need to adapt the reld bold part and change it into the domain in which you play the videos and audios.  So, in this example you change it into:

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.adobe.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<site-control permitted-cross-domain-policies=”master-only”/>
<allow-access-from domain=”*.mystory.com
“/>
</cross-domain-policy>

It’s important that you keep the *. in front of the domain so that you can access files via the following:

  1. http://mystory.com
  2. http://www.mystory.com
  3. http://subdomain.mystory.com
  4. http://deep.subdomain.mystory.com

When that is done, save the file again. 
Now upload it to the bucket that contains the http://gfngnb51f.cloudfront.net distribution.
Flash will automatically look for that file when it encounters a request for an external file.  Since your domain is included in the policy, subtitles and playlists will work now.

What if I want to access the same files from another domain as well?

Simply add a domain to the policy.  If your second domain is called www.mybook.com, we add this: <allow-access-from domain=”*.mybook.com“/>
Thus, we get the following:

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.adobe.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<site-control permitted-cross-domain-policies=”master-only”/>
<allow-access-from domain=”*.mystory.com”/>
<allow-access-from domain=”*.mybook.com“/>

</cross-domain-policy>

Both domains are covered now.  You can add as many domains as you like.  You could also do this: <allow-access-from domain=”*“/> but that means ANY site can access all the files in that bucket too, so that is really not a good idea!

To resume:

  1. Copy the code provided
  2. Change the red part into your own domain name
  3. Safe the file as crossdomain.xml
  4. Upload it to the place from which you want to call files. If you access files from two locations you need to upload the crossdomain policy to both places.

If you want to know more about all possible options, specific info can be found here: http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1

add subtitles.xml to
This entry was posted in Technical articles. Bookmark the permalink.

Leave a Reply