In addition to providing ActionScript reference documentation for our Player APIs, we've packaged all the relevant parts of the API into an ActionScript SWC library. The SWC provides a manifestation of a more formal Player SDK that can be integrated into Flash IDEs. By importing this SWC into their Flash IDEs (such as Adobe Flash CS4 or Flex Builder), Flash and Flex developers can easily integrate Brightcove's player API libraries, making custom player development easier. You can download a zip file that contains the Player API SWC. (Note that code hinting is is not available in the Flash IDE, but is available in Flex Builder, and that the Player API SWC is compatible with Flash CS4, but not CS3 or earlier versions.)
To use the Player API SWC, import the SWC into your project, then wrap the BrightcovePlayer instance (from the ActionScript publishing code) in the BrightcovePlayerWrapper class:
public function SampleWrapper()
{
var player:BrightcovePlayer = new BrightcovePlayer();
_player = new BrightcovePlayerWrapper(player);
_player.addEventListener(ExperienceEvent.TEMPLATE_LOADED, onTemplateLoaded);
addChild(_player);
}private function onTemplateLoaded(evt:ExperienceEvent):void
{
_player.removeEventListener(ExperienceEvent.TEMPLATE_LOADED, onTemplateLoaded);
_experienceModule = _player.getModule(APIModules.EXPERIENCE) as ExperienceModule;
_experienceModule.addEventListener(ExperienceEvent.TEMPLATE_READY, onTemplateReady);
}
Once you wrap the BrightcovePlayer instance in the BrightcovePlayerWrapper class, the wrapper takes the BrightcovePlayer, modules, DTOs and events (which otherwise would all be Object instances) and wraps them in the Player API SWC. This enables strong typing and code hinting in your Flash IDE. Then, instead of having to use all the Objects and magic strings you can use classes and constants:
_experienceModule = _player.getModule(APIModules.EXPERIENCE) as ExperienceModule; _experienceModule.addEventListener(ExperienceEvent.TEMPLATE_READY, onTemplateReady);
For a more complete example that uses the Player API SWC, see the FlexSearchWithSWC example in the Player API examples. For more information about using the Player API SWC, check out this article in the Developer Center.