Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,755 @@
package movie
{
import com.sbi.client.KeepAlive;
import com.sbi.popup.SBYesNoPopup;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.printing.PrintJob;
import flash.printing.PrintJobOrientation;
import gui.DarkenManager;
import gui.FeedbackManager;
import gui.LoadingSpiral;
import loader.MediaHelper;
import localization.LocalizationManager;
public class MovieManager
{
public static const NORMAL_SKIN:int = 1;
public static const BRADY_BARR_SKIN:int = 2;
public static const TIERNEY_THYS_SKIN:int = 3;
public static const BIGGER_FRAME:int = 5;
public static const VID_PLAYER_MEDIA_ID:int = 39;
public static const VID_SELECTOR_MEDIA_ID:int = 202;
private const MOVIES_PER_SCREEN:int = 4;
private var _popupLayer:DisplayLayer;
private var _movieSelector:MovieClip;
private var _movieSelectorPopup:MovieClip;
private var _closeCallback:Function;
private var _pageNumber:int;
private var _mediaItems:Array;
private var _previewImages:Array;
private var _videoArray:Array;
private var _videoPlayer:VideoPlayerOSMF;
private var _spirals:Array;
private var _movieMediaHelper:MediaHelper;
private var _printMediaHelper:MediaHelper;
private var _previewArray:Array;
private var _baseTitles:Array;
private var _indivTitles:Array;
private var _videoPlayerId:int;
private var _theaterScreen:Object;
private var _isFromTheater:Boolean;
private var _isAsking:Boolean;
private var _titleTxt:String;
private var _statusIds:Array;
private var _subtitleIds:Array;
private var _chooseRandom:Boolean;
private var _printMediaHolder:Array;
private var _numPrintItemsToLoad:int;
private var _numPrintItemsLoaded:int;
private var _loadedImages:Array;
private var _randomPlayerSkinId:int;
private var _shouldRepeat:Boolean;
private var _defaultWidth:int = 512;
private var _defaultHeight:int = 288;
private var _skinFrameId:int = 1;
private var _closeBtn:MovieClip;
private var _leftArrow:MovieClip;
private var _rightArrow:MovieClip;
private var _mw0:MovieClip;
private var _mw1:MovieClip;
private var _mw2:MovieClip;
private var _mw3:MovieClip;
private var _playMovBtn0:MovieClip;
private var _playMovBtn1:MovieClip;
private var _playMovBtn2:MovieClip;
private var _playMovBtn3:MovieClip;
public function MovieManager()
{
super();
}
public function init(guiLayer:DisplayLayer, initTheaterScreen:Object, initPreviews:Array, initVideos:Array, initBaseTitles:Array, initIndivTitles:Array, initStatusIds:Array, initSubtitleIds:Array, initMediaId:int = 202, initVideoPlayerId:int = 39, initCloseCallback:Function = null) : void
{
this._popupLayer = guiLayer;
if(initMediaId > 0)
{
this._movieMediaHelper = new MediaHelper();
this._movieMediaHelper.init(initMediaId,this.movieHelperCallback);
}
this._closeCallback = initCloseCallback;
if(Boolean(initTheaterScreen))
{
if(initTheaterScreen is MovieClip)
{
this._theaterScreen = initTheaterScreen;
}
else if(initTheaterScreen.hasOwnProperty("loader"))
{
this._theaterScreen = initTheaterScreen.loader.content;
}
}
this._videoPlayer = new VideoPlayerOSMF();
if(Boolean(this._theaterScreen))
{
MovieClip(this._theaterScreen).addChild(this._videoPlayer);
this._isFromTheater = true;
}
else
{
guiLayer.addChild(this._videoPlayer);
this._isFromTheater = false;
}
this._pageNumber = 0;
this._videoPlayerId = initVideoPlayerId;
this._spirals = new Array();
this._previewImages = new Array();
this._mediaItems = new Array();
this._videoArray = initVideos;
this._previewArray = initPreviews;
this._baseTitles = initBaseTitles;
this._indivTitles = initIndivTitles;
this._statusIds = initStatusIds;
this._subtitleIds = initSubtitleIds;
}
public function get videoPlayer() : VideoPlayerOSMF
{
return this._videoPlayer;
}
public function destroy() : void
{
var i:int = 0;
this.removeListeners();
KeepAlive.stopKATimer(this._movieSelectorPopup);
this._popupLayer.removeChild(this._movieSelectorPopup);
DarkenManager.unDarken(this._movieSelectorPopup);
this._movieSelectorPopup = null;
this._movieSelector = null;
this._isFromTheater = false;
this._isAsking = false;
this._theaterScreen = null;
this._titleTxt = null;
this._movieMediaHelper.destroy();
this._movieMediaHelper = null;
if(Boolean(this._printMediaHelper))
{
this._printMediaHelper.destroy();
this._printMediaHelper = null;
}
if(Boolean(this._mediaItems))
{
for(i = 0; i < this._mediaItems.length; i++)
{
this._mediaItems[0].destroy();
}
this._mediaItems.splice(0,this._mediaItems.length);
this._mediaItems = null;
}
for(var j:int = 0; j < this._spirals.length; j++)
{
this._spirals[j].destroy();
}
if(Boolean(this._videoPlayer))
{
this._videoPlayer.destroy();
}
this._spirals = null;
this._previewImages = null;
this._mediaItems = null;
this._videoArray = null;
this._previewArray = null;
this._baseTitles = null;
this._indivTitles = null;
this._statusIds = null;
this._closeBtn = null;
this._leftArrow = null;
this._rightArrow = null;
this._mw0 = null;
this._mw1 = null;
this._mw2 = null;
this._mw3 = null;
this._playMovBtn0 = null;
this._playMovBtn1 = null;
this._playMovBtn2 = null;
this._playMovBtn3 = null;
this._closeCallback = null;
}
public function toggleVisibility() : void
{
if(Boolean(this._movieSelectorPopup))
{
if(this._movieSelectorPopup.visible)
{
DarkenManager.unDarken(this._movieSelectorPopup);
}
else
{
DarkenManager.darken(this._movieSelectorPopup);
}
this._movieSelectorPopup.visible = !this._movieSelectorPopup.visible;
}
}
public function setSkinFrame(frameId:int) : void
{
this._skinFrameId = frameId;
if(Boolean(this._movieSelector) && this._movieSelector.currentFrame != frameId)
{
this._movieSelector.gotoAndPlay(frameId);
}
}
public function setQuestionBtn() : void
{
if(Boolean(this._movieSelector) && Boolean(this._movieSelector.askTab))
{
if(Boolean(this._movieSelector.askTab.hasOwnProperty("askBradyBtn")))
{
this._movieSelector.askTab.askBradyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn,false,0,true);
}
else
{
this._movieSelector.askTab.askTierneyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn,false,0,true);
}
}
else
{
this._isAsking = true;
}
}
public function setTitleTxt(text:String) : void
{
if(Boolean(this._movieSelector))
{
LocalizationManager.translateId(this._movieSelector.titleTxt,int(text));
}
else
{
this._titleTxt = text;
}
}
public function chooseRandom(isRandom:Boolean, videoPlayerSkinId:int = 1, shouldRepeat:Boolean = false, width:int = 530, height:int = 298) : void
{
this._chooseRandom = isRandom;
this._randomPlayerSkinId = videoPlayerSkinId;
if(Boolean(this._movieSelector) && this._chooseRandom)
{
this._videoPlayer.init(this._videoArray,this._subtitleIds,this._indivTitles,this._videoPlayerId,-1,shouldRepeat,width,height,this.onVideoPlayerClose);
this._videoPlayer.setSkinFrame(videoPlayerSkinId);
this.toggleVisibility();
}
}
public function setShouldRepeat(value:Boolean) : void
{
this._shouldRepeat = value;
}
public function setDefaultWidthHeight(width:int, height:int) : void
{
this._defaultWidth = width;
this._defaultHeight = height;
}
private function movieHelperCallback(img:MovieClip) : void
{
var i:int = 0;
var j:int = 0;
var movieMediaHelper:MediaHelper = null;
if(Boolean(img))
{
DarkenManager.showLoadingSpiral(false);
this._movieSelectorPopup = img;
KeepAlive.startKATimer(this._movieSelectorPopup);
this._movieSelectorPopup.visible = false;
this._popupLayer.addChild(this._movieSelectorPopup);
this._movieSelector = MovieClip(this._movieSelectorPopup.getChildAt(0));
if(this._movieSelector.currentFrame != this._skinFrameId)
{
this._movieSelector.gotoAndPlay(this._skinFrameId);
}
for(i = 1; i < Math.min(5,this._previewArray.length + 1); i++)
{
this._spirals[i - 1] = new LoadingSpiral(this._movieSelector["mw" + i].itemLayer);
}
for(j = 0; j < this._previewArray.length; j++)
{
movieMediaHelper = new MediaHelper();
movieMediaHelper.init(this._previewArray[j],this.previewHelperCallback,true);
this._mediaItems[j] = movieMediaHelper;
}
this._movieSelectorPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._movieSelectorPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._closeBtn = MovieClip(this._movieSelectorPopup.getChildAt(0)["bx"]);
this._leftArrow = this._movieSelector["arrowLBtn"];
this._rightArrow = this._movieSelector["arrowRBtn"];
this._mw0 = this._movieSelector["mw1"];
this._mw1 = this._movieSelector["mw2"];
this._mw2 = this._movieSelector["mw3"];
this._mw3 = this._movieSelector["mw4"];
this._playMovBtn0 = this._mw0["playMovBtn"];
this._playMovBtn1 = this._mw1["playMovBtn"];
this._playMovBtn2 = this._mw2["playMovBtn"];
this._playMovBtn3 = this._mw3["playMovBtn"];
this._playMovBtn0.visible = false;
this._playMovBtn1.visible = false;
this._playMovBtn2.visible = false;
this._playMovBtn3.visible = false;
this._mw0.movieDescTxt.visible = false;
this._mw1.movieDescTxt.visible = false;
this._mw2.movieDescTxt.visible = false;
this._mw3.movieDescTxt.visible = false;
this._mw0.newTag.visible = false;
this._mw1.newTag.visible = false;
this._mw2.newTag.visible = false;
this._mw3.newTag.visible = false;
if(this._videoArray.length <= 4)
{
this._leftArrow.activateGrayState(true);
this._rightArrow.activateGrayState(true);
}
if(!this._isAsking)
{
if(Boolean(this._movieSelector.askTab))
{
this._movieSelector.askTab.visible = false;
}
}
if(Boolean(this._titleTxt))
{
LocalizationManager.translateId(this._movieSelector.titleTxt,int(this._titleTxt));
}
this.addListeners();
if(!this._theaterScreen)
{
this.toggleVisibility();
}
if(Boolean(this._theaterScreen))
{
this._videoPlayer.init(this._videoArray,this._subtitleIds,this._indivTitles,-1,-1);
}
if(this._chooseRandom)
{
this._videoPlayer.init(this._videoArray,this._subtitleIds,this._indivTitles,this._videoPlayerId,-1,this._shouldRepeat,512,288,this.onVideoPlayerClose);
this._videoPlayer.setSkinFrame(this._randomPlayerSkinId);
this.toggleVisibility();
}
}
}
private function onVideoPlayerClose() : void
{
this.onClose(null);
}
private function addListeners() : void
{
this._closeBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._playMovBtn0.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlay,false,0,true);
this._playMovBtn1.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlay,false,0,true);
this._playMovBtn2.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlay,false,0,true);
this._playMovBtn3.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlay,false,0,true);
this._leftArrow.addEventListener(MouseEvent.MOUSE_DOWN,this.onSideBtn,false,0,true);
this._rightArrow.addEventListener(MouseEvent.MOUSE_DOWN,this.onSideBtn,false,0,true);
this._movieSelectorPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onMoviePopup,false,0,true);
if(this._isAsking)
{
if(Boolean(this._movieSelector.askTab))
{
if(Boolean(this._movieSelector.askTab.hasOwnProperty("askBradyBtn")))
{
this._movieSelector.askTab.askBradyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn,false,0,true);
}
else
{
this._movieSelector.askTab.askTierneyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn,false,0,true);
}
}
}
}
private function removeListeners() : void
{
this._closeBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._playMovBtn0.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlay);
this._playMovBtn1.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlay);
this._playMovBtn2.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlay);
this._playMovBtn3.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlay);
this._leftArrow.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSideBtn);
this._rightArrow.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSideBtn);
this._movieSelectorPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMoviePopup);
if(this._isAsking)
{
if(Boolean(this._movieSelector.askTab))
{
if(Boolean(this._movieSelector.askTab.hasOwnProperty("askBradyBtn")))
{
this._movieSelector.askTab.askBradyBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn);
}
else
{
this._movieSelector.askTab.askTierneyBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onAskBtn);
}
}
}
}
private function onMoviePopup(e:MouseEvent) : void
{
e.stopPropagation();
}
private function onClose(e:MouseEvent) : void
{
if(Boolean(e))
{
e.stopPropagation();
}
if(this._closeCallback != null)
{
if(!this._chooseRandom)
{
this._closeCallback();
}
}
else
{
this.destroy();
}
}
private function onAskBtn(e:MouseEvent) : void
{
e.stopPropagation();
DarkenManager.showLoadingSpiral(true);
if(e.currentTarget.name == "askBradyBtn")
{
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_ASK_BRADY);
}
else
{
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_ASK_TIERNEY);
}
}
private function previewHelperCallback(img:MovieClip) : void
{
var currPage:MovieClip = null;
var i:int = 0;
var image:Object = null;
for(var j:int = 0; j < this._mediaItems.length; j++)
{
if(this._mediaItems[j] == img.mediaHelper)
{
this._previewImages[j] = img;
if(j < 4)
{
currPage = this["_mw" + j];
this._spirals[j].destroy();
currPage.movieDescTxt.visible = true;
currPage.playMovBtn.visible = true;
currPage.itemLayer.addChild(img);
LocalizationManager.translateId(currPage.movieDescTxt,this._baseTitles[j]);
currPage.newTag.visible = this._statusIds[j] == 1;
image = img.getChildAt(0);
for(i = 0; i < image.numChildren; i++)
{
if(image.getChildAt(i).name.indexOf("beakerBtn") >= 0)
{
image.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN,this.onBeakerDown,false,0,true);
}
}
}
break;
}
}
if(this._mediaItems.length < 4)
{
for(i = int(this._mediaItems.length); i < 4; i++)
{
this["_mw" + i].visible = false;
}
}
}
private function reloadPreviews() : void
{
var i:int = 0;
var currPage:MovieClip = null;
var image:Object = null;
for(i = 1; i < 5; i++)
{
while(this._movieSelector["mw" + i].itemLayer.numChildren > 0)
{
this._movieSelector["mw" + i].itemLayer.removeChildAt(0);
}
}
for(var j:int = this._pageNumber; j < this._pageNumber + 4; j++)
{
currPage = this["_mw" + (j - this._pageNumber)];
if(j < this._previewImages.length)
{
currPage.visible = true;
currPage.itemLayer.addChild(this._previewImages[j]);
currPage.playMovBtn.visible = true;
LocalizationManager.translateId(currPage.movieDescTxt,this._baseTitles[j]);
currPage.newTag.visible = this._statusIds[j] == 1;
image = this._previewImages[j].getChildAt(0);
for(i = 0; i < image.numChildren; i++)
{
if(image.getChildAt(i).name.indexOf("beakerBtn") > 0)
{
image.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN,this.onBeakerDown,false,0,true);
}
}
}
else
{
currPage.visible = false;
}
}
}
private function onPlay(e:MouseEvent) : void
{
var increment:int = 0;
e.stopPropagation();
switch(e.currentTarget.parent.name)
{
case "mw1":
break;
case "mw2":
increment = 1;
break;
case "mw3":
increment = 2;
break;
case "mw4":
increment = 3;
}
if(this._videoArray.length > increment + this._pageNumber)
{
if(this._chooseRandom || this._isFromTheater)
{
this._videoPlayer.playVideoIdx(this._pageNumber + increment);
this.onClose(e);
}
else
{
this._videoPlayer.init(this._videoArray,this._subtitleIds,this._indivTitles,this._videoPlayerId,this._pageNumber + increment,this._shouldRepeat,this._defaultWidth,this._defaultHeight);
this._videoPlayer.setSkinFrame(this._skinFrameId);
}
}
}
private function onSideBtn(e:MouseEvent) : void
{
var modNum:int = 0;
e.stopPropagation();
switch(e.currentTarget.name)
{
case "arrowLBtn":
if(this._pageNumber - 4 >= 0)
{
this._pageNumber -= 4;
this.reloadPreviews();
}
else if(this._videoArray.length > 4)
{
modNum = this._videoArray.length % 4;
this._pageNumber = this._videoArray.length;
this._pageNumber -= modNum == 0 ? 4 : modNum;
this.reloadPreviews();
}
break;
default:
if(this._pageNumber + 4 < this._videoArray.length)
{
this._pageNumber += 4;
this.reloadPreviews();
}
else
{
this._pageNumber = 0;
this.reloadPreviews();
}
}
}
private function onBeakerDown(evt:MouseEvent) : void
{
evt.stopPropagation();
new SBYesNoPopup(this._popupLayer,LocalizationManager.translateIdOnly(14808),true,this.onConfirmPrint,evt.currentTarget.name.split("_"));
}
private function onConfirmPrint(o:Object) : void
{
var i:int = 0;
if(Boolean(o.status))
{
DarkenManager.showLoadingSpiral(true);
this._numPrintItemsToLoad = o.passback.length - 1;
this._numPrintItemsLoaded = 0;
this._printMediaHolder = [];
this._loadedImages = [];
for(i = 1; i < o.passback.length; i++)
{
this._printMediaHelper = new MediaHelper();
this._printMediaHelper.init(o.passback[i],this.onPrintMediaLoaded,i);
this._printMediaHolder.push(this._printMediaHelper);
}
}
}
private function onPrintMediaLoaded(img:MovieClip) : void
{
var printJob:PrintJob = null;
var i:int = 0;
var printSprites:Array = null;
var o:Object = null;
this._loadedImages[img.passback - 1] = img;
++this._numPrintItemsLoaded;
if(this._numPrintItemsLoaded == this._numPrintItemsToLoad)
{
DarkenManager.showLoadingSpiral(false);
printJob = new PrintJob();
if(printJob.start())
{
printSprites = [];
for(i = 0; i < this._loadedImages.length; i++)
{
o = this.setupPrintSprite(this._loadedImages[i],printJob);
printSprites.push(o.spriteToPrint);
this._printMediaHolder[i].destroy();
try
{
printJob.addPage(o.spriteToPrint,new Rectangle(0,0,o.realW + 2,o.realH + 2));
}
catch(e:Error)
{
}
}
o = null;
}
this._loadedImages = null;
this._printMediaHolder = null;
printJob.send();
if(Boolean(printSprites))
{
for(i = 0; i < printSprites.length; i++)
{
if(Boolean(printSprites[i].parent))
{
gMainFrame.stage.removeChild(printSprites[i]);
}
}
}
printSprites = null;
}
}
private function setupPrintSprite(img:MovieClip, printJob:PrintJob) : Object
{
var cscaleX:Number = NaN;
var cscaleY:Number = NaN;
var imageToPrint:Sprite = new Sprite();
img.scaleX = img.scaleY = 4;
imageToPrint.addChild(img);
img.x = img.y = 1;
var realW:Number = imageToPrint.width;
var realH:Number = imageToPrint.height;
var jpgSource:BitmapData = new BitmapData(imageToPrint.width,imageToPrint.height,false,4294967295);
jpgSource.draw(imageToPrint);
var theBitMap:Bitmap = new Bitmap(jpgSource);
var spriteToPrint:Sprite = new Sprite();
spriteToPrint.addChild(theBitMap);
theBitMap.x = 0;
theBitMap.y = 0;
theBitMap.scaleX = 0.999;
theBitMap.scaleY = 0.999;
spriteToPrint.x = 0;
spriteToPrint.y = 0;
gMainFrame.stage.addChild(spriteToPrint);
spriteToPrint.visible = false;
if(printJob.orientation != PrintJobOrientation.PORTRAIT)
{
spriteToPrint.rotation = 90;
spriteToPrint.x = spriteToPrint.width;
cscaleX = printJob.pageWidth / realH;
cscaleY = printJob.pageHeight / realW;
}
else
{
cscaleX = printJob.pageWidth / realW;
cscaleY = printJob.pageHeight / realH;
}
spriteToPrint.scaleX = spriteToPrint.scaleY = Math.min(cscaleX,cscaleY);
return {
"spriteToPrint":spriteToPrint,
"realW":realW,
"realH":realH
};
}
}
}
@@ -0,0 +1,177 @@
package movie
{
public class MovieNode
{
private var _titleId:int;
private var _streamId:int;
private var _streamTitleId:int;
private var _mediaId:int;
private var _iconMediaId:int;
private var _thumbMediaId:int;
private var _choices:Object;
private var _denRewardId:int;
private var _userVarId:int;
private var _bitIndex:int;
private var _defId:int;
private var _numChoices:int;
private var _hasChosenThisChoice:Boolean;
private var _subtitleId:int;
protected var _thisChapterHasGift:Boolean;
protected var _isChapter:Boolean;
public function MovieNode(node:Object)
{
super();
this._defId = node.defId;
this._titleId = node.titleStrRef;
this._streamId = node.streamRefId;
this._streamTitleId = node.streamTitleStrRef;
this._mediaId = node.mediaRefId;
this._iconMediaId = node.iconMediaRefId;
this._thumbMediaId = node.thumbMediaRefId;
this._choices = {
"choice1Id":node.choice1MovieNodeRefId,
"choice2Id":node.choice2MovieNodeRefId,
"choice3Id":node.choice3MovieNodeRefId
};
this._denRewardId = node.denItemRefId;
this._userVarId = node.userVarRefId;
this._bitIndex = node.userVarBit;
this._numChoices = node.numChoices;
this._subtitleId = node.subtitleId;
node = null;
}
public function get defId() : int
{
return this._defId;
}
public function get titleId() : int
{
return this._titleId;
}
public function get streamId() : int
{
return this._streamId;
}
public function get streamTitleId() : int
{
return this._streamTitleId;
}
public function get mediaId() : int
{
return this._mediaId;
}
public function get iconMediaId() : int
{
return this._iconMediaId;
}
public function get thumbMediaId() : int
{
return this._thumbMediaId;
}
public function getChoiceById(id:int) : int
{
return this._choices["choice" + id + "Id"];
}
public function get choice1Id() : int
{
return this._choices.choice1Id;
}
public function get choice2Id() : int
{
return this._choices.choice2Id;
}
public function get choice3Id() : int
{
return this._choices.choice3Id;
}
public function get denRewardId() : int
{
return this._denRewardId;
}
public function get userVarId() : int
{
return this._userVarId;
}
public function get bitIndex() : int
{
return this._bitIndex;
}
public function get numChoices() : int
{
return this._numChoices;
}
public function set thisChapterHasGift(value:Boolean) : void
{
this._thisChapterHasGift = value;
}
public function get thisChapterHasGift() : Boolean
{
return this._thisChapterHasGift;
}
public function get isChapter() : Boolean
{
return this._isChapter;
}
public function set isChapter(value:Boolean) : void
{
this._isChapter = value;
}
public function get hasChosenThisChoice() : Boolean
{
return this._hasChosenThisChoice;
}
public function set hasChosenThisChoice(value:Boolean) : void
{
this._hasChosenThisChoice = value;
}
public function get subtitleId() : int
{
return this._subtitleId;
}
public function set subtitleId(id:int) : void
{
this._subtitleId = id;
}
}
}
@@ -0,0 +1,49 @@
package movie
{
public class MovieTreeNode extends MovieNode
{
private var _isCorrectChoice:Boolean;
private var _nodeIndex:int;
private var _parentDefId:int;
public function MovieTreeNode(node:Object)
{
super(node);
this.nodeIndex = 1;
}
public function get isCorrectChoice() : Boolean
{
return this._isCorrectChoice;
}
public function set isCorrectChoice(value:Boolean) : void
{
this._isCorrectChoice = value;
}
public function get nodeIndex() : int
{
return this._nodeIndex;
}
public function set nodeIndex(value:int) : void
{
this._nodeIndex = value;
}
public function get parentDefId() : int
{
return this._parentDefId;
}
public function set parentDefId(value:int) : void
{
this._parentDefId = value;
}
}
}
@@ -0,0 +1,229 @@
package movie
{
import loader.DefPacksDefHelper;
public class MovieXtCommManager
{
private static var _movieNodeDefs:Object;
private static var _movieTrees:Object = {};
public function MovieXtCommManager()
{
super();
}
public static function movieNodeResponse(dfdh:DefPacksDefHelper) : void
{
var movieNodeDef:Object = null;
var data:Object = null;
var newDef:Object = dfdh.def;
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_MOVIE_NODE] = null;
var movieNodeDefs:Object = new Object();
for each(data in dfdh.def)
{
movieNodeDef = {
"choice1MovieNodeRefId":int(data.choice1MovieNodeRefId),
"choice2MovieNodeRefId":int(data.choice2MovieNodeRefId),
"choice3MovieNodeRefId":int(data.choice3MovieNodeRefId),
"mediaRefId":int(data.mediaRefId),
"iconMediaRefId":int(data.iconMediaRefId),
"thumbMediaRefId":int(data.thumbMediaRefId),
"denItemRefId":int(data.denItemRefId),
"titleStrRef":int(data.titleStrRef),
"streamRefId":int(data.streamRefId),
"streamTitleStrRef":int(data.streamTitleStrRef),
"userVarRefId":int(data.userVarRefId),
"userVarBit":int(data.userVarBit),
"subtitleId":int(data.subtitleRefId),
"defId":int(data.id),
"numChoices":0
};
movieNodeDef.numChoices = movieNodeDef.choice3MovieNodeRefId > 0 ? 3 : (movieNodeDef.choice2MovieNodeRefId > 0 ? 2 : (movieNodeDef.choice1MovieNodeRefId > 0 ? 1 : 0));
movieNodeDefs[movieNodeDef.defId] = movieNodeDef;
}
_movieNodeDefs = movieNodeDefs;
getAllContinuingNodes(1);
}
public static function get movieDefs() : Object
{
return _movieNodeDefs;
}
public static function getMovieDef(id:int) : MovieNode
{
return new MovieNode(_movieNodeDefs[id]);
}
public static function getMovieNodeFromTree(baseNodeId:int, defId:int) : MovieNode
{
if(_movieTrees[baseNodeId] != null)
{
return _movieTrees[baseNodeId][defId];
}
return null;
}
public static function getAllContinuingNodes(baseNodeId:int) : Array
{
var mtd:MovieTreeNode = null;
if(_movieTrees[baseNodeId] == null)
{
_movieTrees[baseNodeId] = new Object();
_movieTrees[baseNodeId][baseNodeId] = getTreeMovieDef(baseNodeId);
buildNodeTree(_movieTrees[baseNodeId][baseNodeId],baseNodeId);
}
var correctNodes:Array = [];
for each(mtd in _movieTrees[baseNodeId])
{
if(mtd.isCorrectChoice)
{
correctNodes.push(mtd);
}
}
return correctNodes;
}
public static function getAllChapters(baseNodeId:int) : Array
{
var mtd:MovieTreeNode = null;
if(_movieTrees[baseNodeId] == null)
{
_movieTrees[baseNodeId] = new Object();
_movieTrees[baseNodeId][baseNodeId] = getTreeMovieDef(baseNodeId);
buildNodeTree(_movieTrees[baseNodeId][baseNodeId],baseNodeId);
}
var chapterNodes:Array = [];
for each(mtd in _movieTrees[baseNodeId])
{
if(mtd.isChapter)
{
chapterNodes.push(mtd);
}
}
return chapterNodes;
}
public static function resetAllChosenChapters(baseNodeId:int) : void
{
var mtd:MovieTreeNode = null;
for each(mtd in _movieTrees[baseNodeId])
{
if(mtd.hasChosenThisChoice)
{
mtd.hasChosenThisChoice = false;
}
}
}
private static function getTreeMovieDef(id:int) : MovieTreeNode
{
return new MovieTreeNode(_movieNodeDefs[id]);
}
private static function contains(baseNodeId:int, id:int) : int
{
var childLength:int = 0;
var i:int = 0;
if(_movieTrees[baseNodeId] != null)
{
childLength = int(_movieTrees[baseNodeId].length);
for(i = 0; i < childLength; i++)
{
if(_movieTrees[baseNodeId][i].defId == id)
{
return i;
}
}
}
return -1;
}
private static function buildNodeTree(currNode:MovieTreeNode, baseNodeId:int) : void
{
var parent:MovieTreeNode = null;
if(currNode.nodeIndex > 3)
{
if(currNode.defId != baseNodeId)
{
parent = _movieTrees[baseNodeId][currNode.parentDefId];
++parent.nodeIndex;
buildNodeTree(parent,baseNodeId);
}
return;
}
if(currNode.getChoiceById(currNode.nodeIndex) == 0)
{
if(currNode.defId == baseNodeId)
{
++currNode.nodeIndex;
buildNodeTree(currNode,baseNodeId);
}
else
{
if(currNode.userVarId != 0)
{
currNode.isChapter = true;
}
if(currNode.denRewardId > 0)
{
if(currNode.isChapter)
{
currNode.thisChapterHasGift = true;
}
else if(currNode.parentDefId != 0)
{
_movieTrees[baseNodeId][currNode.parentDefId].thisChapterHasGift = true;
}
}
currNode.isCorrectChoice = true;
parent = _movieTrees[baseNodeId][currNode.parentDefId];
++parent.nodeIndex;
buildNodeTree(parent,baseNodeId);
}
return;
}
var currChoiceNode:MovieTreeNode = getTreeMovieDef(currNode.getChoiceById(currNode.nodeIndex));
if(currChoiceNode == null || currChoiceNode.nodeIndex > 3)
{
throw new Error("CurrChoiceNode was null or we are past 3rd index");
}
if(currChoiceNode.defId == currNode.parentDefId)
{
currNode.isChapter = false;
parent = _movieTrees[baseNodeId][currChoiceNode.defId];
if(parent.defId != currChoiceNode.defId)
{
throw new Error("Parent def id did not match current choices def id");
}
++parent.nodeIndex;
buildNodeTree(parent,baseNodeId);
}
else
{
if(currNode.userVarId != 0)
{
currNode.isChapter = true;
}
if(currNode.denRewardId > 0)
{
if(currNode.isChapter)
{
currNode.thisChapterHasGift = true;
}
else
{
_movieTrees[baseNodeId][currNode.parentDefId].thisChapterHasGift = true;
}
}
currNode.isCorrectChoice = true;
_movieTrees[baseNodeId][currChoiceNode.defId] = currChoiceNode;
currChoiceNode.parentDefId = currNode.defId;
buildNodeTree(currChoiceNode,baseNodeId);
}
}
}
}
@@ -0,0 +1,784 @@
package movie
{
import avatar.UserCommXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.corelib.audio.SBAudio;
import com.sbi.loader.LoaderCache;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.Timer;
import flash.utils.getDefinitionByName;
import gui.DarkenManager;
import gui.GuiManager;
import gui.LoadingSpiral;
import loader.MediaHelper;
import localization.LocalizationManager;
import org.osmf.captioning.CaptioningPluginInfo;
import org.osmf.captioning.model.Caption;
import org.osmf.captioning.model.CaptionFormat;
import org.osmf.captioning.model.CaptionStyle;
import org.osmf.containers.MediaContainer;
import org.osmf.elements.VideoElement;
import org.osmf.events.BufferEvent;
import org.osmf.events.DisplayObjectEvent;
import org.osmf.events.LoadEvent;
import org.osmf.events.MediaElementEvent;
import org.osmf.events.MediaErrorEvent;
import org.osmf.events.MediaFactoryEvent;
import org.osmf.events.MediaPlayerCapabilityChangeEvent;
import org.osmf.events.MediaPlayerStateChangeEvent;
import org.osmf.events.PlayEvent;
import org.osmf.events.TimeEvent;
import org.osmf.events.TimelineMetadataEvent;
import org.osmf.media.DefaultMediaFactory;
import org.osmf.media.MediaElement;
import org.osmf.media.MediaFactoryItem;
import org.osmf.media.MediaPlayer;
import org.osmf.media.MediaResourceBase;
import org.osmf.media.PluginInfoResource;
import org.osmf.media.URLResource;
import org.osmf.metadata.Metadata;
import org.osmf.metadata.TimelineMetadata;
import org.osmf.net.DynamicStreamingResource;
import org.osmf.net.NetLoader;
import org.osmf.net.StreamType;
import org.osmf.net.StreamingURLResource;
import org.osmf.traits.MediaTraitType;
import org.osmf.utils.FCSubscribeHandler;
public class VideoPlayerOSMF extends Sprite
{
private var _videoMediaHelper:MediaHelper;
private var _playerPopup:MovieClip;
private var _videoLayer:Sprite;
private var _videoPlayer:MediaPlayer;
private var _loadingSpiral:LoadingSpiral;
private var _currVideoIdx:int;
private var _videos:Array;
private var _videoDesc:Array;
private var _subtitleIds:Array;
private var _loadText:TextField;
private var _hasMediaId:Boolean;
private var _skinFrameId:int = 1;
private var _subTitleTextField:TextField;
private var _graySubtitleBox:MovieClip;
private var _musicMutedByPlayer:Boolean;
private var _isReady:Boolean;
private var _isPaused:Boolean;
private var _readyToStart:Boolean;
private var _popupLoaded:Boolean;
private var _netConnected:Boolean;
private var _playerWidth:int;
private var _playerHeight:int;
private var _info:Object;
private var _shouldRepeatSingleMovie:Boolean;
private var _container:MediaContainer;
private var _videoElement:MediaElement;
private var _mediaFactory:DefaultMediaFactory;
private var _FCS:FCSubscribeHandler;
private var _isLive:Boolean;
private var _bufferTimer:Timer;
private var _startUpTimer:Timer;
private var _captionMetadata:TimelineMetadata;
private var _theaterWindow:MovieClip;
private var _mouseOverTimer:Timer;
private var _closeCallback:Function;
public function VideoPlayerOSMF()
{
super();
}
public function init(initVideos:Array, initSubtitleIds:Array, initVideoDesc:Array = null, initMediaId:int = -1, initCurrVideoIdx:int = -1, initShouldRepeat:Boolean = true, initWidth:Number = 512, initHeight:Number = 288, initCloseCallback:Function = null) : void
{
this._videos = initVideos;
this._videoDesc = initVideoDesc;
this._subtitleIds = initSubtitleIds;
this._playerWidth = initWidth;
this._playerHeight = initHeight;
this._shouldRepeatSingleMovie = initShouldRepeat;
this._currVideoIdx = initCurrVideoIdx;
this._closeCallback = initCloseCallback;
this._mouseOverTimer = new Timer(10,300);
this._mouseOverTimer.addEventListener(TimerEvent.TIMER,this.onMouseOverTimer,false,0,true);
if(this._currVideoIdx >= this._videos.length || this._currVideoIdx < 0)
{
this._currVideoIdx = Math.round(Math.random() * (this._videos.length - 1));
}
if(initMediaId >= 0)
{
this._videoMediaHelper = new MediaHelper();
this._videoMediaHelper.init(initMediaId,this.mediaHelperCallback);
this._hasMediaId = true;
}
this._startUpTimer = new Timer(5000);
this._videoPlayer = new MediaPlayer();
this._container = new MediaContainer();
this._mediaFactory = new DefaultMediaFactory();
if(LocalizationManager.currentLanguage != LocalizationManager.LANG_ENG)
{
this.loadPlugin("org.osmf.captioning.CaptioningPluginInfo");
}
this._container.width = this._playerWidth;
this._container.height = this._playerHeight;
this._videoPlayer.autoPlay = true;
this._videoPlayer.autoRewind = initShouldRepeat;
this._videoPlayer.addEventListener(MediaPlayerCapabilityChangeEvent.CAN_PLAY_CHANGE,this.canPlay,false,0,true);
this._videoPlayer.addEventListener(PlayEvent.PLAY_STATE_CHANGE,this.onStateChange,false,0,true);
this._videoPlayer.addEventListener(BufferEvent.BUFFERING_CHANGE,this.onBufferChange,false,0,true);
this._videoPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE,this.onMediaPlayerStateChange,false,0,true);
this._videoPlayer.addEventListener(DisplayObjectEvent.MEDIA_SIZE_CHANGE,this.onMediaSizeChange,false,0,true);
this._videoPlayer.addEventListener(TimeEvent.COMPLETE,this.completeHandler,false,0,true);
if(this._hasMediaId)
{
this._videoPlayer.addEventListener(LoadEvent.BYTES_LOADED_CHANGE,this.onBytesLoadedChange,false,0,true);
}
if(this._isLive)
{
this._videoPlayer.addEventListener(BufferEvent.BUFFER_LENGTH_CHANGE,this.onBufferLengthChange,false,0,true);
}
this._videoPlayer.currentTimeUpdateInterval = 100;
if(this._hasMediaId)
{
this._container.x -= this._playerWidth * 0.5;
this._container.y -= this._playerHeight * 0.5;
UserCommXtCommManager.sendPermEmote(542,false);
SBTracker.push();
}
else
{
DarkenManager.showLoadingSpiral(false);
this._theaterWindow = MovieClip(this.parent);
this._theaterWindow.parent.mouseEnabled = true;
this._theaterWindow.parent.mouseChildren = true;
this._loadingSpiral = new LoadingSpiral(this._theaterWindow,this._theaterWindow.width * 0.5,this._theaterWindow.height * 0.5);
this._theaterWindow.hoverState.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayPauseBtn,false,0,true);
this._theaterWindow.hoverState.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
this._theaterWindow.hoverState.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this._theaterWindow.playPauseBtn.visible = false;
this._theaterWindow.playPauseBtn.gotoAndStop("pause");
this._theaterWindow.videoLayer.addChild(this._container);
this._subTitleTextField = this._theaterWindow.subtitle;
this._subTitleTextField.htmlText = "";
this._graySubtitleBox = this._theaterWindow.grayBox;
this._graySubtitleBox.visible = false;
this._popupLoaded = true;
this.playVideoIdx(this._currVideoIdx);
}
}
private function loadPlugin(source:String) : void
{
var pluginResource:MediaResourceBase = null;
var pluginInfoRef:Class = null;
if(source.substr(0,4) == "http" || source.substr(0,4) == "file")
{
pluginResource = new URLResource(source);
}
else
{
pluginInfoRef = getDefinitionByName(source) as Class;
pluginResource = new PluginInfoResource(new pluginInfoRef());
}
this.loadPluginFromResource(pluginResource);
}
private function loadPluginFromResource(pluginResource:MediaResourceBase) : void
{
this._mediaFactory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD,this.onPluginLoaded);
this._mediaFactory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR,this.onPluginLoadFailed);
this._mediaFactory.loadPlugin(pluginResource);
}
private function onPluginLoaded(event:MediaFactoryEvent) : void
{
trace("Plugin LOADED!");
}
private function onPluginLoadFailed(event:MediaFactoryEvent) : void
{
trace("Plugin LOAD FAILED!");
}
private function onPlayPauseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.parent.playPauseBtn.currentFrameLabel != "play")
{
this._videoPlayer.pause();
this._mouseOverTimer.reset();
evt.currentTarget.parent.playPauseBtn.gotoAndStop("play");
}
else if(evt.currentTarget.parent.playPauseBtn.currentFrameLabel != "pause")
{
evt.currentTarget.parent.playPauseBtn.gotoAndStop("pause");
this._videoPlayer.play();
this._mouseOverTimer.start();
evt.currentTarget.parent.playPauseBtn.alpha = 1;
}
}
private function onRollOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.parent.playPauseBtn.currentFrameLabel != "play")
{
this._mouseOverTimer.reset();
evt.currentTarget.parent.playPauseBtn.visible = false;
}
}
private function onRollOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.parent.playPauseBtn.currentFrameLabel != "play")
{
this._mouseOverTimer.start();
evt.currentTarget.parent.playPauseBtn.alpha = 1;
evt.currentTarget.parent.playPauseBtn.visible = true;
}
}
private function onMouseOverTimer(t:TimerEvent) : void
{
if(t.currentTarget.currentCount > 200)
{
if(Boolean(this._theaterWindow))
{
this._theaterWindow.playPauseBtn.alpha -= 0.01;
}
else if(Boolean(this._playerPopup))
{
this._playerPopup.playPauseBtn.alpha -= 0.01;
}
if(t.currentTarget.currentCount == this._mouseOverTimer.repeatCount)
{
this._mouseOverTimer.reset();
}
}
}
private function onBytesLoadedChange(evt:LoadEvent) : void
{
evt.stopPropagation();
if(Boolean(this._playerPopup.loadTxt))
{
this._playerPopup.loadTxt.text = int(evt.bytes / evt.currentTarget.bytesTotal * 100) + "%";
}
}
private function onBufferLengthChange(evt:BufferEvent) : void
{
if(evt.bufferLength <= 0.01)
{
this._bufferTimer = new Timer(10000);
this._bufferTimer.addEventListener(TimerEvent.TIMER,this.onCheckBufferLength);
this._bufferTimer.start();
}
else if(Boolean(this._bufferTimer))
{
this._bufferTimer.stop();
this._bufferTimer.removeEventListener(TimerEvent.TIMER,this.onCheckBufferLength);
this._bufferTimer = null;
}
}
private function onMediaPlayerStateChange(evt:MediaPlayerStateChangeEvent) : void
{
evt.stopPropagation();
if(evt.state == "buffering")
{
}
if(evt.state == "playing")
{
}
}
private function onCheckBufferLength(e:TimerEvent) : void
{
new SBOkPopup(GuiManager.guiLayer,"This video is not available anymore.");
}
private function onBufferChange(evt:BufferEvent) : void
{
evt.stopPropagation();
if(evt.buffering)
{
this.addSpiral();
}
else
{
this.removeSpiral();
}
}
private function onTimeEvent(evt:TimeEvent) : void
{
}
private function canPlay(evt:MediaPlayerCapabilityChangeEvent) : void
{
if(Boolean(this._startUpTimer))
{
this._startUpTimer.addEventListener(TimerEvent.TIMER,this.onStartupCheck);
this._startUpTimer.start();
}
}
private function onMediaSizeChange(evt:DisplayObjectEvent) : void
{
if(Boolean(this._startUpTimer))
{
this._startUpTimer.stop();
this._startUpTimer.removeEventListener(TimerEvent.TIMER,this.onStartupCheck);
this._startUpTimer = null;
}
}
private function onStartupCheck(t:TimerEvent) : void
{
this._startUpTimer.stop();
this._startUpTimer.removeEventListener(TimerEvent.TIMER,this.onStartupCheck);
this._startUpTimer = null;
}
private function onStateChange(evt:PlayEvent) : void
{
if(evt.playState == "playing")
{
SBTracker.trackPageview("/game/play/video/#" + this._videos[this._currVideoIdx]);
}
}
public function destroy() : void
{
this.destroyPlayerItems();
if(Boolean(this._videoMediaHelper))
{
this._videoMediaHelper.destroy();
this._videoMediaHelper = null;
}
if(Boolean(this._playerPopup))
{
this._playerPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
this._playerPopup.visible = false;
this._playerPopup = null;
}
if(Boolean(this._loadingSpiral))
{
this._loadingSpiral.destroy();
this._loadingSpiral = null;
}
this._videos = null;
this._videoDesc = null;
if(this._musicMutedByPlayer)
{
this._musicMutedByPlayer = false;
SBAudio.unmuteMusic(false);
}
if(this._hasMediaId)
{
UserCommXtCommManager.sendPermEmote(-1,false);
}
}
public function toggleSound() : void
{
if(this._videoPlayer.volume == 0)
{
this._videoPlayer.volume = 1;
}
else
{
this._videoPlayer.volume = 0;
}
}
public function setSkinFrame(frameId:int) : void
{
this._skinFrameId = frameId;
if(Boolean(this._playerPopup) && this._playerPopup.currentFrame != this._skinFrameId)
{
this._playerPopup.gotoAndPlay(this._skinFrameId);
}
}
private function destroyPlayerItems() : void
{
if(Boolean(this._startUpTimer))
{
this._startUpTimer.stop();
this._startUpTimer.removeEventListener(TimerEvent.TIMER,this.onStartupCheck);
this._startUpTimer = null;
}
if(Boolean(this._bufferTimer))
{
this._bufferTimer.stop();
this._bufferTimer.removeEventListener(TimerEvent.TIMER,this.onCheckBufferLength);
this._bufferTimer = null;
}
if(Boolean(this._videoPlayer))
{
this._videoPlayer.stop();
this._videoPlayer.media = null;
if(this._container.containsMediaElement(this._videoElement))
{
this._container.removeMediaElement(this._videoElement);
}
while(this._container.numChildren > 0)
{
this._container.removeChildAt(0);
}
this._videoPlayer.removeEventListener(MediaPlayerCapabilityChangeEvent.CAN_PLAY_CHANGE,this.canPlay);
this._videoPlayer.removeEventListener(PlayEvent.PLAY_STATE_CHANGE,this.onStateChange);
this._videoPlayer.removeEventListener(BufferEvent.BUFFERING_CHANGE,this.onBufferChange);
this._videoPlayer.removeEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE,this.onMediaPlayerStateChange);
this._videoPlayer.removeEventListener(DisplayObjectEvent.MEDIA_SIZE_CHANGE,this.onMediaSizeChange);
if(this._isLive)
{
this._videoPlayer.removeEventListener(BufferEvent.BUFFER_LENGTH_CHANGE,this.onBufferLengthChange);
}
this._videoElement = null;
this._container = null;
this._videoPlayer = null;
this._mediaFactory = null;
}
}
private function mediaHelperCallback(mc:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
if(Boolean(mc))
{
this._playerPopup = MovieClip(mc.getChildAt(0));
if(this._playerPopup.currentFrame != this._skinFrameId)
{
this._playerPopup.gotoAndPlay(this._skinFrameId);
}
GuiManager.guiLayer.addChild(this._playerPopup);
if(Boolean(this._videoDesc) && this._videoDesc.length > 0)
{
LocalizationManager.translateId(this._playerPopup.videoTitleTxt,this._videoDesc[this._currVideoIdx]);
}
else
{
LocalizationManager.translateId(this._playerPopup.videoTitleTxt,11392);
}
this._playerPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._playerPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._playerPopup.itemLayer.addChild(this._container);
this._playerPopup["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._playerPopup.hoverState.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayPauseBtn);
this._playerPopup.hoverState.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
this._playerPopup.hoverState.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this._playerPopup.playPauseBtn.visible = false;
this._playerPopup.playPauseBtn.gotoAndStop("pause");
this._playerPopup.loadTxt.text = "0%";
this._subTitleTextField = this._playerPopup.subtitle;
this._subTitleTextField.htmlText = "";
this._graySubtitleBox = this._playerPopup.grayBox;
this._graySubtitleBox.visible = false;
this._playerPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
DarkenManager.darken(this._playerPopup);
this._loadingSpiral = new LoadingSpiral(this._playerPopup.itemLayer);
this._popupLoaded = true;
this.playVideoIdx(this._currVideoIdx);
}
}
public function playVideoIdx(idx:int) : void
{
this._currVideoIdx = idx;
this.playNonStreaming();
}
private function playNonStreaming() : void
{
var metadata:Metadata = null;
var resource:URLResource = new URLResource(LoaderCache.fetchCDNURL("streams/" + this._videos[this._currVideoIdx] + ".flv"));
this.onHideCaption(null);
if(LocalizationManager.currentLanguage != LocalizationManager.LANG_ENG && this._subtitleIds[this._currVideoIdx] != 0)
{
metadata = new Metadata();
metadata.addValue(CaptioningPluginInfo.CAPTIONING_METADATA_KEY_URI,LoaderCache.fetchCDNURL("subtitle/" + this._subtitleIds[this._currVideoIdx] + "/" + LocalizationManager.currentLanguage));
MediaResourceBase(resource).addMetadataValue(CaptioningPluginInfo.CAPTIONING_METADATA_NAMESPACE,metadata);
}
var netLoader:NetLoader = new NetLoader();
this._mediaFactory.addItem(new MediaFactoryItem("org.osmf.elements.video",netLoader.canHandleResource,this.createVideoElement));
this._videoElement = this._mediaFactory.createMediaElement(resource);
this._videoElement.addEventListener(MediaElementEvent.TRAIT_ADD,this.onTraitAdd);
this._captionMetadata = this._videoElement.getMetadata(CaptioningPluginInfo.CAPTIONING_TEMPORAL_METADATA_NAMESPACE) as TimelineMetadata;
if(this._captionMetadata == null)
{
this._captionMetadata = new TimelineMetadata(this._videoElement);
this._videoElement.addMetadata(CaptioningPluginInfo.CAPTIONING_TEMPORAL_METADATA_NAMESPACE,this._captionMetadata);
}
this._captionMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REACHED,this.onShowCaption);
this._captionMetadata.addEventListener(TimelineMetadataEvent.MARKER_ADD,this.onHideCaption);
this._videoElement.addEventListener(MediaErrorEvent.MEDIA_ERROR,this.onMediaError,false,0,true);
this.setMediaElement(this._videoElement);
this.enablePlayerControls(true);
if(!SBAudio.isMusicMuted)
{
SBAudio.muteMusic(false);
this._musicMutedByPlayer = true;
}
else
{
this._videoPlayer.volume = 0;
}
}
private function setMediaElement(value:MediaElement) : void
{
if(this._videoPlayer.media != null && this._container.containsMediaElement(this._videoPlayer.media))
{
this._container.removeMediaElement(this._videoPlayer.media);
}
if(value != null)
{
this._container.addMediaElement(value);
}
this._videoPlayer.media = value;
}
private function enablePlayerControls(enable:Boolean = true) : void
{
}
private function createVideoElement() : MediaElement
{
return new VideoElement();
}
private function onTraitAdd(event:MediaElementEvent) : void
{
switch(event.traitType)
{
case MediaTraitType.SEEK:
}
}
private function onShowCaption(event:TimelineMetadataEvent) : void
{
var caption:Caption = event.marker as Caption;
if(caption != null)
{
this._subTitleTextField.htmlText = caption.text;
if(!this._graySubtitleBox.visible)
{
this._graySubtitleBox.visible = true;
}
}
}
private function onHideCaption(event:TimelineMetadataEvent) : void
{
this._subTitleTextField.htmlText = "";
this._graySubtitleBox.visible = false;
}
private function onMediaError(event:MediaErrorEvent) : void
{
trace("Media Load Error : " + event.error.errorID + " - " + event.error.message);
}
private function formatCaption(caption:Caption) : void
{
var captionFormat:CaptionFormat = null;
var txtFormat:TextFormat = null;
var style:CaptionStyle = null;
for(var i:uint = 0; i < caption.numCaptionFormats; i++)
{
captionFormat = caption.getCaptionFormatAt(i);
txtFormat = new TextFormat();
style = captionFormat.style;
if(style.textColor != null)
{
txtFormat.color = style.textColor;
}
if(style.fontFamily != "")
{
txtFormat.font = style.fontFamily;
}
if(style.fontSize > 0)
{
txtFormat.size = style.fontSize;
}
if(style.fontStyle != "")
{
txtFormat.italic = style.fontStyle == "italic" ? true : false;
}
if(style.fontWeight != "")
{
txtFormat.bold = style.fontWeight == "bold" ? true : false;
}
if(style.textAlign != "")
{
txtFormat.align = style.textAlign;
}
this._playerPopup.subtitle.setTextFormat(txtFormat,captionFormat.startIndex,captionFormat.endIndex);
if(this._playerPopup.subtitle.wordWrap != style.wrapOption)
{
this._playerPopup.subtitle.wordWrap = style.wrapOption;
}
}
}
private function onSMILPluginLoaded(evt:MediaFactoryEvent) : void
{
var myResource:DynamicStreamingResource = new DynamicStreamingResource("http://wac.6A16.edgecastcdn.net/006A16/IntroVideo/manifest.smil",StreamType.RECORDED);
myResource.urlIncludesFMSApplicationInstance = true;
this._videoElement = this._mediaFactory.createMediaElement(myResource);
this._videoPlayer.media = this._videoElement;
this._videoPlayer.bufferTime = 6;
this._container.addMediaElement(this._videoElement);
if(SBAudio.isMusicMuted)
{
this._videoPlayer.volume = 0;
}
}
private function playLiveStream(idx:int) : void
{
this._FCS = new FCSubscribeHandler();
this._FCS.run("mba_opensea","rtmp://fml.6A16.edgecastcdn.net/206A16",this);
}
public function fcSubscribeDone() : void
{
var myResource:StreamingURLResource = new StreamingURLResource("rtmp://fml.6A16.edgecastcdn.net/206A16/mba_opensea",StreamType.LIVE);
this._videoElement = this._mediaFactory.createMediaElement(myResource);
this._videoPlayer.media = this._videoElement;
this._videoPlayer.bufferTime = 6;
this._container.addMediaElement(this._videoElement);
if(SBAudio.isMusicMuted)
{
this._videoPlayer.volume = 0;
}
}
private function onPluginLoadError(evt:MediaFactoryEvent) : void
{
trace("FAILED TO LOAD PLUGIN");
}
private function completeHandler(evt:TimeEvent) : void
{
this.addSpiral();
this._videoPlayer.stop();
this._container.removeMediaElement(this._videoElement);
if(this._currVideoIdx < this._videos.length - 1)
{
++this._currVideoIdx;
}
else
{
this._currVideoIdx = 0;
}
if(this._shouldRepeatSingleMovie)
{
this.playVideoIdx(this._currVideoIdx);
}
else
{
this.onClose(null);
}
}
private function onClose(e:MouseEvent) : void
{
if(Boolean(e))
{
e.stopPropagation();
}
DarkenManager.unDarken(this._playerPopup);
if(this._hasMediaId)
{
SBTracker.pop();
}
this.destroy();
if(this._closeCallback != null)
{
this._closeCallback();
this._closeCallback = null;
}
}
private function removeSpiral() : void
{
if(this._hasMediaId)
{
if(Boolean(this._playerPopup.itemLayer.contains(this._loadingSpiral)))
{
this._playerPopup.itemLayer.removeChild(this._loadingSpiral);
}
}
else if(this._theaterWindow.contains(this._loadingSpiral))
{
this._theaterWindow.removeChild(this._loadingSpiral);
}
}
private function addSpiral() : void
{
if(this._hasMediaId)
{
if(Boolean(this._loadingSpiral) && !this._playerPopup.itemLayer.contains(this._loadingSpiral))
{
this._playerPopup.itemLayer.addChild(this._loadingSpiral);
}
}
else if(Boolean(this._loadingSpiral) && !this._theaterWindow.contains(this._loadingSpiral))
{
this._theaterWindow.addChild(this._loadingSpiral);
}
}
private function mouseDown(e:MouseEvent) : void
{
e.stopPropagation();
}
}
}