3

Boy-oh-boy我讨厌外部接口吗?我有一个视频播放器,利用外部接口来控制Flash对象,并允许Flash对象将消息传递给相同的JavaScript。一段时间以来,它在所有浏览器中运行良好。然后前几天我就去在所有浏览器进行测试之前,我感动项目进行开发,并发现该应用程序在Internet Explorer 9打破在控制台中出现以下错误:外部接口和Internet Explorer 9问题

SCRIPT16389: Could not complete the operation due to error 8070000c. 
jquery.min.js, line 16 character 29366 

我JavaScript文件真的很长,但这里是重要的部分。我所有的行为都包含在我创建的对象中。里面的我的方法之一,我有以下行:

var that = this; 
that.stop(); 

这里是所有被调用作为方法的结果的方法:

this.stop = function(){ 
    var that = this; 
    console.log('stop called'); 
    that.pause(); 
    that.seek(0); 
    that.isPlaying = false; 
    console.log('stop finished'); 
}; 

this.pause = function(){ 
    var that = this; 
     console.log('pause called'); 
    if(that.player == 'undefined' || that.player == null){ 
     that.player = that.GetMediaObject(that.playerID); 
    } 
    that.player.pauseMedia(); //external interface call 
    that.isPlaying = false; 
    console.log('pause finished'); 
}; 

this.seek = function(seek){     
    var that = this; 
    console.log('seek called'); 
    if(that.player == 'undefined' || that.player ==null){ 
     console.log("player="+that.player+". resetting player object"); 
     that.player = that.GetMediaObject(that.playerID); 
     console.log("player="+that.player); 
    } 
    that.player.scrubMedia(seek); //external interface call 

    console.log('seek finished');    
}; 

//this method returns a reference to my player. This method is call once when the page loads and then again as necessary by all methods that make external interface calls 
this.GetMediaObject = function(playerID){ 
    var mediaObj = swfobject.getObjectById(playerID); 
     console.log('fetching media object: ' +mediaObj); 

     //if swfobject.getObjectById fails 
     if(typeof mediaObj == 'undefined' || mediaObj == null){ 
       console.log('secondary fetch required'); 
     var isIE = navigator.userAgent.match(/MSIE/i); 
     mediaObj = isIE ? window[playerID] : document[playerID]; 
    } 

    return mediaObj; 
}; 

下面是从我的console.log statments输出:

LOG: fetching media object: [object HTMLObjectElement] 
LOG: video-obj-1: ready 
LOG: stop called 
LOG: pause called 
LOG: pause finished 
LOG: seek called 
LOG: player=[object HTMLObjectElement] 
SCRIPT16389: Could not complete the operation due to error 8070000c. 
jquery.min.js, line 16 character 29366 

有趣的是,它似乎是第一个外部接口调用“that.player.pauseMedia()”没有任何问题,但后续调用“that.player.scrubMedi一个(0)'失败。另一个奇怪的是,它指向jquery作为错误的来源,但在这些函数中没有对jquery的调用。

这是我所知道的不是。这不是我的时机关闭的问题。当flash对象完全加载时,我的动作的最后一行向javascript发送消息。另外我将参数'allowScriptAccess'设置为'always',所以它不是那样。我们使用的actionscript文件已经在以前的项目中使用过,所以我90%确定这不是问题。

这里是我的动作无论如何。我没有写动作,我不是太熟悉的语言,但我试图把似乎最为相关的我的应用程序的部分:

flash.system.Security.allowDomain("*.mydomain.com"); 

import flash.external.ExternalInterface; 

// variables to store local information about the current media 
var mediaEmbedServer:String = "www"; 
var mediaPlayerID:String; 
var mediaFile:String; 
var mediaDuration:Number; 

// variables to be watched by actionscript and message javascript on changes 
var mediaPositions:String = "0,0"; // buffer position, scrub position 
var mediaStatus:String; 

var netStreamClient:Object = new Object(); 
netStreamClient.onMetaData = metaDataHandler; 
netStreamClient.onCuePoint = cuePointHandler; 

var connection:NetConnection; 
var stream:NetStream; 
var media:Video = new Video(); 

// grab the media's duration when it becomes available 
function metaDataHandler(info:Object):void { 
mediaDuration = info.duration; 
} 

function cuePointHandler(info:Object):void { 
} 

connection = new NetConnection(); 
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); 

try { 
var paramName:String; 
var paramValue:String; 
var paramObject:Object = LoaderInfo(this.root.loaderInfo).parameters; 
for (paramName in paramObject) { 
paramValue = String(paramObject[paramName]); 
switch (paramName){ 
case "server": 
mediaEmbedServer = paramValue; 
break 
case "playerID": 
mediaPlayerID = paramValue; 
break 
} 
} 
} catch (error:Error) { 
} 

if (mediaEmbedServer == "dev" || mediaEmbedServer == "dev2"){ 
connection.connect("rtmp://media.developmentMediaServer.com/myApp"); 
} else { 
connection.connect("rtmp://media.myMediaServer.com/myApp"); 
} 

function securityErrorHandler(event:SecurityErrorEvent):void { 
trace("securityErrorHandler: " + event); 
} 

function connectStream():void { 
stream = new NetStream(connection); 
stream.soundTransform = new SoundTransform(1); 
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
stream.client = netStreamClient; 
media.attachNetStream(stream); 
media.width = 720; 
media.height = 405; 
addChild(media); 
} 

function netStatusHandler(stats:NetStatusEvent){ 
switch (stats.info.code){ 
case "NetConnection.Connect.Success": 
connectStream(); 
break; 
case "NetConnection.Call.BadVersion": 
case "NetConnection.Call.Failed": 
case "NetConnection.Call.Prohibited": 
case "NetConnection.Connect.AppShutdown": 
case "NetConnection.Connect.Failed": 
case "NetConnection.Connect.InvalidApp": 
case "NetConnection.Connect.Rejected": 
case "NetGroup.Connect.Failed": 
case "NetGroup.Connect.Rejected": 
case "NetStream.Connect.Failed": 
case "NetStream.Connect.Rejected": 
case "NetStream.Failed": 
case "NetStream.Play.Failed": 
case "NetStream.Play.FileStructureInvalid": 
case "NetStream.Play.NoSupportedTrackFound": 
case "NetStream.Play.StreamNotFound": 
case "NetStream.Seek.Failed": 
case "NetStream.Seek.InvalidTime": 
// report error status and reset javascriptPlay 
clearInterval(progressInterval); 
messageStatus("error"); 
break; 
default: 
// check time through file to determine if media is over 
if (stream.time > 0 && stream.time >= (mediaDuration - .25)){ 
// reset media if it has ended 
clearInterval(progressInterval); 
stream.play(mediaFile, 0, 0); 
messageStatus("finished"); 
} 
} 
}; 

var progressInterval:Number; 

// respond to a play/pause request by playing/pausing the current stream 
function pauseMedia(){ 
clearInterval(progressInterval); 
if (mediaStatus == 'playing'){ 
stream.pause(); 
messageStatus("paused"); 
} 
}; 
ExternalInterface.addCallback("pauseMedia", pauseMedia); 

// respond to a scrub request by seeking to a position in the media 
function scrubMedia(newPosition){ 
clearInterval(progressInterval); 
if (mediaStatus == "playing"){ 
stream.pause(); 
messageStatus("paused"); 
} 
stream.seek(newPosition * mediaDuration); 
var positionSeconds = newPosition * mediaDuration; 
messagePositions(positionSeconds+","+positionSeconds); 
}; 
ExternalInterface.addCallback("scrubMedia", scrubMedia); 


ExternalInterface.call("MediaPlayerReady", mediaPlayerID); 

回答

0

听起来像一个undefined expando property可以由jQuery IE9 bug引起。调试它的最好方法是,除去的userAgent测试和用对象元件的检查替换它,如:

document.getElementsByTagName("object")[0].outerHTML 

看有无ID属性由jQuery的第一次点击之后被改变。

0

我有使用JPEGCam,也使用Flash的外部接口这个问题。我的摄像头控制被动态加载到一个div中,然后将这个错误引入IE(不是Firefox或Chrome)。将闪存控件的初始化移动到父页面中的document.ready后,根据需要隐藏/显示/移动控件,我可以解决此异常。

希望有所帮助。