Menu

[r50]: / trunk / preloader / FlashMediaPlayback / src / FlashMediaPlayback.as  Maximize  Restore  History

Download this file

124 lines (106 with data), 4.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*****************************************************
*
* 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;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.