/*****************************************************
*
* Copyright 2010 Adobe Systems Incorporated. All Rights Reserved.
*
*****************************************************
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Adobe Systems Incorporated.
* Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems
* Incorporated. All Rights Reserved.
*
*****************************************************/
package
{
import com.adobe.rsl.RuntimeSharedLibrariesLoader;
import com.adobe.rsl.RuntimeSharedLibrary;
import com.adobe.rsl.RuntimeSharedLibraryEvent;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.events.Event;
import flash.system.ApplicationDomain;
import flash.text.TextField;
import flash.utils.getDefinitionByName;
[SWF(frameRate="25", backgroundColor="0x000000")]
public class FlashMediaPlayback extends MovieClip
{
/*
* Please keep the following lines as is!
* the ant build script that generates the swz
* will look for this line and will replace
* the digest value to the one it calculates for the swz.
* If you change the spacing/qualifiers/constant name, make sure
* you update the ant script also !!!
*/
public static const STROBE_SWZ_DIGEST:String = '5c546ab32ac98ffa8028d0faef715372ec4490ddf65712b73b813646bf135927';
public static const STROBE_SWZ_URL:String = 'StrobeMediaPlayback_1.0.10000_for_fp10.0.swz';
public function FlashMediaPlayback()
{
super();
stop();
parameters = loaderInfo ? loaderInfo.parameters : {};
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(event:Event):void
{
stage.align = StageAlign.TOP_LEFT;
libraryLoader = new RuntimeSharedLibrariesLoader();
var preloaderUrl:String = loaderInfo.loaderURL;
var lastSeparatorPosition:int = preloaderUrl.lastIndexOf("/");
var baseUrl:String = (lastSeparatorPosition > 0) ? preloaderUrl.substr(0, lastSeparatorPosition + 1) : "";
libraryLoader.addRSL(
new RuntimeSharedLibrary
( baseUrl + STROBE_SWZ_URL
, STROBE_SWZ_DIGEST
));
libraryLoader.addEventListener(RuntimeSharedLibraryEvent.LOAD_SUCCESS, onRSLLoadComplete);
libraryLoader.addEventListener(RuntimeSharedLibraryEvent.LOAD_ERROR, onRSLLoadError);
libraryLoader.load();
}
private function onRSLLoadComplete(event:RuntimeSharedLibraryEvent):void
{
instantiatePlayer();
}
private function onRSLLoadError(event:RuntimeSharedLibraryEvent):void
{
trace("error loading rsl list: " + event.numLibrariesFailed);
trace(event.toString());
instantiatePlayer();
}
private function instantiatePlayer():void
{
graphics.clear();
if (ApplicationDomain.currentDomain.hasDefinition("StrobeMediaPlayback"))
{
var playerClass:Class = getDefinitionByName("StrobeMediaPlayback") as Class;
var playerInstance:Object = new playerClass();
playerInstance.initialize(parameters, stage);
addChild(playerInstance as DisplayObject);
}
else
{
var errorText:TextField = new TextField();
errorText.width = stage.stageWidth;
errorText.multiline = true;
errorText.htmlText = '<P ALIGN="CENTER"><FONT FACE="Arial" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">Error loading Flash Media Playback components!</FONT></P>';
errorText.y = stage.stageHeight / 2 - errorText.height / 2;
addChild(errorText);
}
nextFrame();
}
private var parameters:Object;
private var libraryLoader:RuntimeSharedLibrariesLoader;
private static const WIDTH:Number = 150;
private static const HEIGHT:Number = 12;
}
}