OK this is well beyond my flash knowledge and was wondering if there is anyone out there that can help. Simply I need to get this Brightcove player working in a flash file, having never worked with AS3 and Classes before I'm at a total loss as to what to do. If its possible (and i know this rather cheeky to ask) could you upload an example .fla
I'm thinking everything I need to know is in the code below but flash has moved on somewhat since i used it a year ago!!
Code:
// By use of this code snippet, I agree to the Brightcove Publisher T&C
// found at http://corp.brightcove.com/legal/terms_publisher.cfm.
/*
* To use this class to load your Brightcove player instance, save this code into the root directory
* of your project as BrightcovePlayer.as. Then, within your application, you can instantiate this player
* using the following syntax:
*
* var player:BrightcovePlayer = new BrightcovePlayer();
* addChild(player); /// must be added to a display object container, such as a Sprite instance
*
*/
package {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.system.SecurityDomain;
import flash.system.Security;
public class BrightcovePlayer extends Sprite {
private var bcPlayer:Object;
public function BrightcovePlayer() {
init();
}
private function init():void {
var config:Object = new Object();
// change the playerID to load a different player
config["playerID"] = 14146705001;
config["width"] = 464;
config["height"] = 394;
Security.allowDomain("http://admin.brightcove.com");
createPlayer(config);
}
private function onPlayerLoadInit(pEvent:Event):void {
var pLoaderInfo:LoaderInfo = pEvent.target as LoaderInfo;
var pLoader:Loader = pLoaderInfo.loader;
var pPlayer:Sprite = pLoaderInfo.content as Sprite;
if (bcPlayer && pPlayer != bcPlayer) {
if (bcPlayer.parent) {
bcPlayer.parent.removeChild(bcPlayer);
}
}
bcPlayer = pPlayer;
addChild(bcPlayer as Sprite);
if (contains(pLoader)) removeChild(pLoader);
}
private function onPlayerLoadProgress(pEvent:ProgressEvent):void {
// place preload feedback here for shell movie
}
private function createPlayer(config:Object):void {
var cacheServerServices:String = "http://c.brightcove.com/services";
var cdnURL:String = "http://admin.brightcove.com";
var publisherID:String = "1815805388";
var configItems:String = "";
for (var i:String in config) {
if (i == "flashID" || i == "width" || i == "height") continue;
configItems += "&" + i + "=" + escape(config[i]);
}
var file:String = cacheServerServices + "/viewer/federated_f9/" +
config["playerID"] + "?isVid=1&isUI=1" +
"&flashID="+escape(config["flashID"])+
"&playerWidth="+escape(config["width"])+
"&playerHeight="+escape(config["height"])+
"&publisherID="+escape(publisherID)+
configItems;
var player:Loader = new Loader();
addChild(player);
player.contentLoaderInfo.addEventListener(Event.INIT, onPlayerLoadInit);
player.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onPlayerLoadProgress);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
player.load(new URLRequest(file), context);
}
public function onTemplateLoaded():void {
dispatchEvent(new Event("templateLoaded"));
}
public function getModule(pModule:String):Object {
return Object(bcPlayer).getModule(pModule);
}
}
}