|Video Cloud||Professional, Enterprise|
Creating an Ad Display SWF requires advanced development skills. This feature is intended for use by ad network and ad serving partners with complex ad delivery requirements. If you are a Video Cloud customer and think your project or product calls for use of the Video Cloud Ad Display SWF, please first contact your Account Manager to see if one of the Video Cloud ad partners would work better for you.
This document describes how to create an Ad Display SWF. By default, a Video Cloud player expects ads to be returned in XML format. Using an Ad SWF enables the use of Flash SWF-based ad components or modules. This opens up many possibilities for how an ad can look and behave.
If you want to deliver and render a unique Ad Format in your Video Cloud player, that is not one of Video Cloud standard Ad Formats, you can develop your own Ad Display SWF. The Ad Display SWF is an advanced tool which is often used for development by advertising partners.
Just like other ad formats, the Ad Display SWF has an XML specification, which looks like this:
<adSwf version="1" trackStartURLs="http://trackingurl"> <adSwfURL>http://path-to-ad-swf.swf</adSwfURL> <optionalArg>arg value 1</optionalArg> <anotherArg>arg value 2</anotherArg> </adSwf>
When the player receives an ad in this format, it retrieves and executes the SWF at the specified URL. The SWF can then make an additional call or calls for the ad content itself as well as handle all the rendering and user events. An Ad Display SWF can be linear or non-linear, acting like a video ad or an overlay ad. Special APIs can make linear ads act similar to the Video Cloud built-in video format.
To help you learn how to write Ad Display SWFs, you can download a zip file,
AdSDK.zip, that includes (under the adswf directory) the following resources:
To learn about creating and using Ad Display SWFs, set up the example and see how it works. The main steps in setting up the example are:
We provide an Ad Translator in the
AdSDK.zip example zip so that you can easily try out the example ad SWF. You do not have to use the example Ad Translator. Instead of using the Ad Translator, you could just traffick the example Ad Display SWF as you would any other ad on your ad server. The Ad Translator, however, allows you to see the Ad Display SWF in the example without trafficking it on your ad server.
To set up the Ad Translator, you can either compile
ExampleTranslator.as or just use the already-compiled
ExampleTranslator.swf. To start with
ExampleTranslator.asfrom the asdwf/example directory in
AdSDK.zip. Create a project in your development environment with
ExampleTranslator.asas the main class.
bc_ads.swcas an external library. Make sure that you add it as an external library, rather than putting it in the library path. Otherwise, your SWF will be slightly larger than it needs to be. If you are using Adobe Flex Builder, you can add it as an external library in the "Additional Compiler Options" by adding
-external-library-path=../bc_ads.swc. If you are using Adobe Flash, you can simply drop
bc_ads.swcinto the same directory as your application
.flabefore you compile.
ExampleTranslator.asand put the resulting SWF on a web server where your players can access it. We'll use this SWF later.
To use the already-compiled
ExampleTranslator.swffrom the asdwf/example directory in
The next step is to compile and host the example Ad Display SWF. You can either compile
ExampleAdSwf.as or just use the already-compiled
Example.swf. To start with
ExampleAdSwf.asfrom the asdwf/example directory in
AdSDK.zip. Copy these files to a different folder than the one used for the Ad Translator project.
ExampleAdSwf.asas the main class.
bc_ads.swcas an external library. Make sure that you add it as an external library, rather than putting it in the library path. Follow the same steps that were done for the ad translator above.
ExampleAdSwf.asand put the resulting SWF on a web server where your players can access it.
Note: You need to make a few changes in your project setup to use both bc_ads.swc and BrightcovePlayerAPI.swc in your Ad Display SWF. Add both bc_ads.swc and BrightcovePlayerAPI.swc as regular libraries if you are using Adobe Flex Builder. You can do this through your project's properties (Library path tab) or in the Additional Compiler Options by adding -library-path=../bc_ads.swc. Also, note line 138 in ExampleAdSwf.as where the AdSwfContext.moduleLoader must be wrapped in com.brightcove.fl.advertising.api.BrightcoveModuleWrapper to be used with both development swcs (ie: moduleLoader = new BrightcoveModuleWrapper(adContext.moduleLoader as IEventDispatcher)). After adding both development swcs and wrapping your moduleLoader, you should be able to type all variables and use the swcs to the fullest.
To use the already-compiled
Example.swffrom the asdwf/example directory in
Now that we have compiled and hosted the Ad Translator SWF and Ad Display SWF, we can use these two elements together to traffick an Ad Display SWF:
adSwf=http://host/adSwf.swf, changing the URL to the actual location of your Ad Display SWF.
Now that you've seen how the Ad Display SWF works in the example, you should be able to see how to create your own Ad Display SWF. You can use the example,
ExampleAdSwf.as, as a starting point. Your Ad Display SWF should follow the same basic structure. Review the comments in
ExampleAdSwf.as to help you understand what is going on. As in
Security.allowDomain("admin.brightcove.com") so thatyou don't need to set up a crossdomain.xml security file to allow the SWF to communicate with the Video Cloud player SWFs.
displayAd()function. This is the function which displays the ad. It will often load another SWF that is the actual ad. The function can change the state of the player or initialize the ad with
AdSwfContext. The player APIs can be accessed through
AdSwfContext,which allows the Ad Display SWF to get information about different BEML components, change the ad display state through functions like showSponsorMessage(), get the size and location of the video player, and a lot more.
adComplete()to return control to the player. Make sure to remove any event listeners that have been set up.