Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 外部接口和Internet Explorer 9问题_Javascript_Debugging_Internet Explorer 9_Actionscript 2_Externalinterface - Fatal编程技术网

Javascript 外部接口和Internet Explorer 9问题

Javascript 外部接口和Internet Explorer 9问题,javascript,debugging,internet-explorer-9,actionscript-2,externalinterface,Javascript,Debugging,Internet Explorer 9,Actionscript 2,Externalinterface,我讨厌外部接口。我有一个视频播放器,它利用外部接口控制flash对象,并允许flash对象将消息传递给同一个javascript。有一段时间,它在所有浏览器中都运行良好。几天前,在我将项目移出开发之前,我在所有浏览器中对其进行了测试,发现该应用程序在InternetExplorer9中出现故障。控制台中出现以下错误: SCRIPT16389: Could not complete the operation due to error 8070000c. jquery.min.js, line 1

我讨厌外部接口。我有一个视频播放器,它利用外部接口控制flash对象,并允许flash对象将消息传递给同一个javascript。有一段时间,它在所有浏览器中都运行良好。几天前,在我将项目移出开发之前,我在所有浏览器中对其进行了测试,发现该应用程序在InternetExplorer9中出现故障。控制台中出现以下错误:

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;
};
以下是my console.log stations的输出:

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.scrubMedia(0)”失败。另一件奇怪的事情是,它指出jquery是错误的来源,但这些函数中没有对jquery的调用

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

这是我的动作脚本。我没有编写actionscript,也不太熟悉该语言,但我尝试加入了与我的应用程序最相关的部分:

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);   
听起来像是一个可能是由。调试它的最佳方法是删除userAgent测试,并将其替换为检查对象元素,例如:

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

查看jQuery第一次单击后ID属性是否被更改。

我在使用JPEGCam时遇到了这个问题,JPEGCam也使用flash的外部接口。我的网络摄像头控件是在一个div中动态加载的,然后会在IE中抛出这个错误(不是firefox或chrome)。在父页面中将flash控件的初始化移动到document.ready,然后根据需要隐藏/显示/移动控件之后,我能够解决此异常

希望有帮助