Advanced Streaming Video Programming
This section walks through how to add streaming video to a rich media ad.
1. Bandwidth Detection
If you need to serve different Flash video content to users of different bandwidths, you will need to edit/modify the code below to check a users’ bandwidth and serve the Flash Video files(s) accordingly.
1.) In the Atlas streaming video code, Find the variable below and Set the following parameter to true.
ARM_bandwidthDetection = true;
2.) In the Streaming Video script, Find the block of code below and Set the ARM_video_ source variables to the Flash video (FLV) files you want to serve at the various bandwidths (Where _root.movieX; corresponds to the Flash video file(s) defined in the Microsoft Rich Media movie variables on your Links and Descriptions layer).
//Selects a video source based on users bandwidth
ARM_stream_connection.onBWDone = function (bandwidthVal)
{
if (bandwidthVal<150) {
ARM_video_source = _root.movie1
} else if (bandwidthVal>150) {
ARM_video_source = _root.movie2
} else if (bandwidthVal == undefined) {
ARM_video_source = _root.movie3;
}
}
Notes: All ARM_video_source variables must be defined. You can choose which ARM_video_ source variable shall contain which Flash video file (low quality, high quality, etc...), or you can have all ARM_video_ source variables call the same Flash Video file.
2. Setting Buffer Time
As a best practice, it is always recommended to set the ad to buffer a specific amount of streamed information before playback begins. Most publishers require the buffer to be 3 seconds long enabling the video stream to flow more smoothly. To do this, you must call the setBufferTime() function, passing it a value, in seconds.
By default buffer time is set to 1 second in the streaming video code. If you need to change the buffer time, Edit the ARM_buffer_size variable according to your needs.
ARM_buffer_size = 3;
3. Streaming from an External Server
You can stream Flash video files from an external streaming server (i.e. not from Microsoft’ servers).
To do so you must define the full path to the Flash video (FLV) file on the external streaming server in your MTK movie variable (found on Links and Descriptions layer)
movie1 = “http://externalserverURL/yourVideo.flv”;
movie2 = “”;
movie3 = “”;
movie4 = “”;
Then edit the _root.streaming_url variable (found in the Microsoft streaming video code) to call the movie variable that is set to the location of the FLV file.
_root.streaming_url = _root.movie1;
4. NetStream Class Methods & Properties Summary
The following methods and properties of the NetConnection and NetStream classes are used to control FLV playback.
a.) Method summary table for the NetStream class
b.) Property summary table for the NetStream class
c.) Event handler summary for the NetStream class
5. Optimal Encoding Values for Flash Streaming Video
Below are recommended target bitrates for your Flash videos (.flv), and suggestions for encoding parameters to reach those targets. Adjust these settings as necessary to optimize your particular video.
High motion video encoding values; lots of zooms, fades and people moving around.
Low motion video encoding values; general talking heads.
