3

Boy-oh-boyは外部インターフェイスを嫌いです。私は外部インターフェイスを使用してフラッシュオブジェクトを制御し、フラッシュオブジェクトが同じ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への後続の呼び出しa(0) 'は失敗します。別の奇妙なことは、エラーの原因としてjqueryを指していることですが、これらの関数ではjqueryの呼び出しはありません。

ここに私はそれがないと知っている。それは私のタイミングがオフになっている問題ではありません。私の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); 

答えて

0

jQuery IE9 bugによって引き起こされる可能性がundefined expando propertyような音。 ID属性は、jQueryのことで最初のクリック後に変更されているかどうかを確認するために

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

:それをデバッグするための最良の方法は、userAgentにテストを削除して、オブジェクト要素のチェックと交換、などのことです。

0

この問題は、Flashの外部インターフェイスも使用するJPEGCamを使用して発生しました。私のwebcamコントロールはdiv内で動的に読み込まれていましたが、このエラーはIE(firefoxやchromeではなく)にスローされます。私のフラッシュコントロールの初期化を親ページのdocument.readyに移動した後、必要に応じてコントロールを隠したり表示したりすることで、この例外を回避することができました。

希望に役立ちます。

関連する問題