Using crossdomain.xml for poster images and subtitles

crossdomain policySubtitle files, poster images and playlists are supposed to reside on your domain due to security restrictions of Flash.  This also is needed if you work with HLS or MPEG-DASH, in HTML5 mode (S3Media Stream works like that). 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 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.
Luckily, 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. Use Notepad on Windows or Text Editor on Mac.


<!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=”*.footprintaddons.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:


<!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

For HLS, this is different. You need to specify the protocol and if you work with a subdomain it is best listed fully as well. Using the examples above, this becomes:

<!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=”*https.https://mystory.com“/>
<allow-access-from domain=”*https.https://www.mystory.com“/>
<allow-access-from domain=”*https.http://subdomain.mystory.com“/>
<allow-access-from domain=”*https.https://deep.subdomain.mystory.com“/>
</cross-domain-policy>

 

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, although playlists are often tricky. We recommend keeping them on your own domain to avoid problems.  After all, they are small files, so the cloud is not going to speed things up.

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:


<!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. Save 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.