| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
When you stream media files using CloudFront, you provide both your media file and the media player with which you want end users to play the media file. To use Adobe Flash Player to stream media files with CloudFront, perform the procedures in the following topics:
This tutorial uses Adobe Flash Builder version 4.6 to generate the files necessary to stream a video using Adobe Flash Player. For more information about Flash Builder, go to the Flash Builder page on the Adobe website. For information about downloading a free trial version of Adobe Flash Builder, go to the Downloads/Adobe Flash Builder 4.6 page.
For a list of the codecs that Flash Player supports, go to the Supported codecs | Flash Player page on the Adobe website.
For more information about streaming media using CloudFront, see Working with Streaming Distributions.
You can upload your media files and your media player files to the same Amazon S3 bucket or to separate buckets. For this tutorial, you'll create one bucket for both a media file and and the Flash Player media player files. You'll upload the files later in the process, after you create the Adobe Flash Player files.
To create an Amazon S3 bucket
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the Amazon S3 console, click Create Bucket.
In the Create Bucket dialog, enter a bucket name.
Important
For your bucket to work with CloudFront, the name must conform to DNS naming requirements. For more information, go to Bucket Restrictions and Limitations in the Amazon Simple Storage Service Developer Guide.
Select a region for your bucket. By default, Amazon S3 creates buckets in the US Standard region. We recommend that you choose a region close to you to optimize latency, minimize costs, or to address regulatory requirements.
Click Create.
To configure CloudFront to stream a media file, you need a CloudFront streaming distribution. For this tutorial, you'll also create a CloudFront download distribution to access the .hlml file that Adobe Flash Builder creates. Perform the following two procedures.
To create a CloudFront download distribution
Open the Amazon CloudFront console at https://console.aws.amazon.com/cloudfront/.
Click Create Distribution.
On the first page of the Create Distribution Wizard, accept the default selection, Download, and click Continue.

On the second page of the wizard, click in the Origin Domain Name field, and select the Amazon S3 bucket that you created in the procedure To create an Amazon S3 bucket. If you have a lot of Amazon S3 buckets, you can type the first few characters of the bucket name to filter the list.

Accept the default values for the remaining fields, and click Create Distribution.
After CloudFront creates your distribution, the value of the Status column for your distribution will change from InProgress to Deployed. This should take less than 15 minutes.
The domain name that CloudFront assigns to your distribution appears in the list of distributions. (It also appears on the General tab for a selected distribution.)
To create a CloudFront streaming distribution
In the CloudFront console, click Create Distribution.
In the Create Distribution Wizard, click Streaming, and click Continue.
On the second page of the wizard, click in the Origin Domain Name field, and select the Amazon S3 bucket that you created in the procedure To create an Amazon S3 bucket. If you have a lot of Amazon S3 buckets, you can type the first few characters of the bucket name to filter the list.

Accept the default values for the remaining fields on the Create Distribution page, and click Create Distribution.
After CloudFront creates your distribution, the value of the Status column for your distribution will change from InProgress to Deployed. This should take less than 15 minutes.
The domain name that CloudFront assigns to your distribution appears in the list of distributions. The domain name also appears on the General tab for a selected distribution.
You can use Adobe Flash Builder to automatically create a Flash project, which contains all of the files necessary to play a media file using Adobe Flash.
To create a Flash project using Adobe Flash Builder
Start Adobe Flash Builder.
On the Flash Builder File menu, click New > Flex Project.
Enter the following values:
Project name: Enter a name for your project, for example, CloudFrontStreaming.
Folder: Specify where you want Flash Builder to save the files for this project. If you don't want to use the default location, uncheck the Use default location checkbox, and choose another location.
Make note of the location; you'll need it later in the process.
Application type: Accept the default value, Web.
Flex SDK version: Accept the default value, Use default SDK.
To create the project, click Finish.
After Flash Builder creates the project, a new tab that has the name of your project appears in the Flash Builder user interface. The Source button on the <project-name> tab is selected, and the Source page contains several lines of XML code.
Delete the default XML code on the Source page.
Copy the following XML code, and paste it into the blank Source page in Adobe Flash Builder.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements here, for example, services and value objects -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import org.osmf.net.StreamingURLResource; import org.osmf.net.FMSURL;
protected function vp_preinitializeHandler(event:FlexEvent): void
{
var myURL:StreamingURLResource = new StreamingURLResource("rtmp://STREAMING-DISTRIBUTION-DOMAIN-NAME/cfx/st/mp4:VIDEO-FILE-NAME-WITHOUT-EXTENSION");
myURL.urlIncludesFMSApplicationInstance = true;
myVideoPlayer.source = myURL;
}
]]>
</fx:Script>
<s:VideoPlayer id="myVideoPlayer" autoPlay="true" preinitialize="vp_preinitializeHandler(event)" x="32" y="52"/>
</s:Application>In the XML code that you pasted into the Source page, replace the following values:
Replace STREAMING-DISTRIBUTION-DOMAIN-NAME with the CloudFront domain name for your
streaming distribution, for example, s5c39gqb8ow64r.cloudfront.net.
Replace VIDEO-FILE-NAME-WITHOUT-EXTENSION with the name of your video file, but
exclude the filename extension. For example, if the name of your video is my-vacation.mp4, enter only
my-vacation.
Save your changes.
On the Flash Builder Project menu, click Export Release Build.
In the Export Release Build dialog box, accept all default values, and click Finish.
Flash Builder creates the files for your project and saves them in the location that you specified in Step 3.
When you use Adobe Flash Builder to generate the files for streaming media files, you upload media files and Flash Builder files to the same Amazon S3 bucket.
To upload your media and Flash Builder files to an Amazon S3 bucket
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the Buckets pane, select your bucket, and click Upload.
On the Upload - Select Files page, click Add Files, and add the following files:
Your media file
The files that Flash Builder generated when you performed the procedure
To create a Flash project using Adobe Flash Builder.
Upload only the files in the bin-release directory. You can exclude the files in the
bin-release/history subdirectory.

Grant public read permissions for the files that you added in the previous step.
Click Set Details.
On the Set Details page, click Set Permissions.
On the Set Permissions page, click Make everything public.
Click Start Upload.
To play the media file, you display the HTML file that Flash Builder created for your project and that you uploaded to your Amazon S3 bucket.
To play the media file
Enter the CloudFront URL of the HTML file that Flash Builder created for your project by concatenating the following values:
http://domain-name-for-your-CloudFront-distribution/HTML-file-name
For example:
http://d111111abcdef8.cloudfront.net/CloudFrontStreaming.html
In the video player, click the arrow button.
The video should begin to play.