我将这个Flash插件修改为JWPlayer,但有些是如何让我的播放器崩溃。当我改变视频时就会发生这种情况,所以我的猜测是它不是删除元素并关闭插件。我试过控制台记录所有内容,并在更改视频时停止console.logging,所以我不知道这个假设。
package {
import com.longtailvideo.jwplayer.events.*;
import com.longtailvideo.jwplayer.player.*;
import com.longtailvideo.jwplayer.plugins.*;
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*
import flash.net.*;
import flash.geom.*;
import flash.external.ExternalInterface;
/** An example plugin that tests various player integrations. **/
public class APITester extends Sprite implements IPlugin6 {
private var api:IPlayer;
private var player:IPlayer;
private var maskedClip:MovieClip;
private var tickertop:TextField;
private var tickermid:TextField;
private var tickertopBg:Sprite;
private var tickermidBg:Sprite;
private var pluginConfig:PluginConfig;
private var isPlaying:Boolean;
private var randNumber:Number;
public function get id():String {
return "apitester";
};
public function get target():String {
return "6.0";
}
public function APITester() {
tickertopBg = new Sprite();
tickertop = new TextField();
tickermidBg = new Sprite();
tickermid = new TextField();
ExternalInterface.call("console.log", randNumber + " : " + "0");
randNumber = Math.floor(Math.random() * (1 - 500000 + 1)) + 5000000;
};
public function initPlugin(player:IPlayer, config:PluginConfig):void {
ExternalInterface.call("console.log", randNumber + " : " + "Start");
api = player;
player = player;
tickertop.htmlText = config['ticker1'];
tickermid.htmlText = config['ticker2'];
tickertopBg.graphics.beginFill(0xe3bfa3,1);
tickertopBg.graphics.drawRect(0,0,stage.stageWidth,30);
tickertopBg.x = 0;
tickertopBg.y = 0;
tickertopBg.visible = false;
tickertopBg.alpha = 0;
tickertopBg.graphics.endFill();
addChild(tickertopBg);
var tickertopFormat:TextFormat = new TextFormat();
tickertopFormat.font = "PT Sans";
tickertopFormat.color = 0x000000;
tickertopFormat.size = 20;
tickertopFormat.bold = true;
tickertop.setTextFormat(tickertopFormat);
tickertop.autoSize = TextFieldAutoSize.LEFT;
tickertop.x = 0;
tickertop.y = 0;
tickertop.height = 30;
tickertop.visible = false;
tickertop.alpha = 0;
//tickertop.width = stage.stageWidth;
tickertop.textColor = 0x000000;
addChild(tickertop);
tickermidBg.graphics.beginFill(0x000000,1);
tickermidBg.graphics.drawRect(0,0,stage.stageWidth,20);
tickermidBg.x = 0;
tickermidBg.y = 30;
tickermidBg.visible = false;
tickermidBg.alpha = 0;
tickermidBg.graphics.endFill();
addChild(tickermidBg);
var tickermidFormat:TextFormat = new TextFormat();
tickermidFormat.font = "PT Sans";
tickermidFormat.size = 16;
tickermidFormat.bold = true;
tickermid.setTextFormat(tickermidFormat);
tickermid.autoSize = TextFieldAutoSize.LEFT;
tickermid.x = 0;
tickermid.y = 29;
tickermid.visible = false;
tickermid.alpha = 0;
tickermid.height = 20;
//tickermid.width = stage.stageWidth;
//tickermid.textColor = 0xFFFFFF;
addChild(tickermid);
api.addEventListener(MediaEvent.JWPLAYER_MEDIA_COMPLETE, completeHandler);
api.addEventListener(Event.ENTER_FRAME,EnterFrame);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseOverStage);
function mouseOverStage(evt:Event):void
{
ExternalInterface.call("console.log", randNumber + " : " + "3");
hideItems();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseOverStage);
stage.addEventListener(Event.MOUSE_LEAVE, mouseOut);
}
function mouseOut(evt:Event):void
{
ExternalInterface.call("console.log", randNumber + " : " + "2");
showItems();
stage.removeEventListener(Event.MOUSE_LEAVE, mouseOut);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseOverStage);
}
api.addEventListener(PlayerStateEvent.JWPLAYER_PLAYER_STATE, stateHandler);
};
public function EnterFrame(event:Event):void {
ExternalInterface.call("console.log", randNumber + " : " + "2");
if (isPlaying) {
tickermid.x -= 5;
ExternalInterface.call("console.log", randNumber + " : " + "20");
if(tickermid.x < -(tickermid.width)) {
ExternalInterface.call("console.log", randNumber + " : " + "21");
tickermid.x = stage.stageWidth;
}
if(tickermid.x > (stage.stageWidth)) {
ExternalInterface.call("console.log", randNumber + " : " + "22");
tickermid.x = -(tickermid.width);
}
tickertop.x -= 4;
if(tickertop.x < -(tickertop.width)) {
ExternalInterface.call("console.log", randNumber + " : " + "23");
tickertop.x = stage.stageWidth;
}
if(tickertop.x > (stage.stageWidth)) {
ExternalInterface.call("console.log", randNumber + " : " + "24");
tickertop.x = -(tickermid.width);
}
}
}
public function showItems():void {
if (isPlaying) {
tickertopBg.visible = true;
tickertopBg.alpha = 1;
tickertop.visible = true;
tickertop.alpha = 1;
tickermidBg.visible = true;
tickermidBg.alpha = 1;
tickermid.visible = true;
tickermid.alpha = 1;
}
};
public function hideItems():void {
tickertopBg.visible = false;
tickertopBg.alpha = 0;
tickertop.visible = false;
tickertop.alpha = 0;
tickermidBg.visible = false;
tickermidBg.alpha = 0;
tickermid.visible = false;
tickermid.alpha = 0;
};
private function completeHandler(evt:MediaEvent):void {
api.removeEventListener(Event.ENTER_FRAME,EnterFrame);
isPlaying = false;
};
private function stateHandler(event:PlayerStateEvent):void {
switch (event.newstate) {
case PlayerState.PAUSED:
ExternalInterface.call("console.log", randNumber + " : " + "50");
break;
case PlayerState.PLAYING:
ExternalInterface.call("console.log", randNumber + " : " + "51");
isPlaying = true;
showItems();
break;
case PlayerState.IDLE:
ExternalInterface.call("console.log", randNumber + " : " + "52");
api.removeEventListener(Event.ENTER_FRAME,EnterFrame);
isPlaying = false;
hideItems();
break;
case PlayerState.BUFFERING:
ExternalInterface.call("console.log", randNumber + " : " + "52");
api.removeEventListener(Event.ENTER_FRAME,EnterFrame);
isPlaying = false;
hideItems();
break;
}
};
/** If the player resizes itself, this gets called (including on setup). **/
public function resize(wid:Number, hei:Number):void {
ExternalInterface.call("console.log", randNumber + " : " + "6");
if(stage.stageWidth == 290) {
var tickertopFormat0:TextFormat = new TextFormat();
tickertopFormat0.size = 12;
tickertop.setTextFormat(tickertopFormat0);
tickertopBg.height = 14;
//
var tickermidFormat0:TextFormat = new TextFormat();
tickermidFormat0.size = 10;
tickermid.setTextFormat(tickermidFormat0);
tickermidBg.height = 12;
//
tickertop.y = hei - (tickertop.height+9);
tickertopBg.y = hei - (tickertopBg.height+12);
tickermid.y = hei - (tickermid.height-2);
tickermidBg.y = hei - (tickermidBg.height);
} else if(stage.stageWidth > 750 && stage.stageWidth != 290) {
//
var tickertopFormat:TextFormat = new TextFormat();
tickertopFormat.size = 48;
tickertop.setTextFormat(tickertopFormat);
tickertopBg.height = 58;
//
var tickermidFormat:TextFormat = new TextFormat();
tickermidFormat.size = 26;
tickermid.setTextFormat(tickermidFormat);
tickermidBg.height = 36;
//
tickertop.y = hei - (tickertop.height+41);
tickertopBg.y = hei - (tickertopBg.height+41);
tickermid.y = hei - (tickermid.height+5);
tickermidBg.y = hei - (tickermidBg.height+5);
} else {
//
var tickertopFormat2:TextFormat = new TextFormat();
tickertopFormat2.size = 20;
tickertop.setTextFormat(tickertopFormat2);
tickertopBg.height = 30;
//
var tickermidFormat2:TextFormat = new TextFormat();
tickermidFormat2.size = 16;
tickermid.setTextFormat(tickermidFormat2);
tickermidBg.height = 24;
//
tickertop.y = hei - (tickertop.height+21);
tickertopBg.y = hei - (tickertopBg.height+20);
tickermid.y = hei - (tickermid.height);
tickermidBg.y = hei - (tickermidBg.height);
}
showItems();
//
tickertop.width = stage.stageWidth;
tickermid.width = stage.stageWidth;
tickertopBg.width = stage.stageWidth;
tickermidBg.width = stage.stageWidth;
};
}
}
有什么想法吗?修改了http://www.pluginsbyethan.com/
中的插件