这是我要嵌入的由swfobject
生成的对象。
<object type="application/x-shockwave-flash"
name="player"
id="player"
data="StrobeMediaPlayback.swf?ID=89.41153136547655"
width="470"
height="320">
<param name="flashvars"
value="verbose=true&src=rtmp://s161ki0ys7euuz.cloudfront.net/cfx/st/_definst_/vid_cdntest001?Signature=q-ZT9mWcIorCwGS4xgOysTyRXoUB2yza~JGITwCwx5O0JObgvlvS728vGXaI0iaow4OA8JRdFOBWYeeLQ5klYcjsWtgjzqH37ZVyV-5pyEUgT80DzWOOM9ZVfd2xBaZjISdn4cNk03FRBZ85~Z4zoEkp8MweE2HEzfrHnzZjoXlaulsPuphg59ANZCGQFneGfSI33dYhzTRDnbZbTZAGilLeu8gjtvfgm9hQ80E1zVd7wuHR8hX7or2ZjTgmDBaq4i-Nj8rJI0w3CIKAOu7JBggvclltbDnzMvy76s4Ef~GowYS7GB0p07Whi512GmGB9W1n6TqUBS-m8QK4vvqC~w__&Key-Pair-Id=APKAJSRQXYNPUENHF6HQ&Expires=1387470161&urlIncludesFMSApplicationInstance=true">
</object>
它嵌入了swf,但是swf没有按预期工作。我的代码正在向swf传递额外的flashvars。
我正在跟踪发送到swf的所有参数/flashvars。我明白了:
PARAMS: = verbose
PARAMS: = Expires
PARAMS: = src
PARAMS: = ID
PARAMS: = urlIncludesFMSApplicationInstance
PARAMS: = Key-Pair-Id
它将
Expires
、ID
和Key-Pair-Id
作为flashvars读取,而这些都应该是src
参数的一部分。原因是flashvar的值:
rtmp://s161ki0ys7euuz.cloudfront.net/cfx/st/vid_cdntest2?Signature=rlBXiKxXRHwSha9YB~GZjyojy8gWZXO18Ea5JLZf1PHvuJFfQE617Ea-5aq8QVoVANaSetnoHQMja76ERxBowjG8cIYxWTGP-UBzP2v-k0hZghNGTtn~qSaFRaSHJGMG59ZKW2EobOHDQxV4r7k-ZG3vAJJpFRm7SoP980DRoJM7J6oAhCUKzZOgv6uRT-StsPORU2Ny3iUx7dIf~QWYBbzfcP1cPrZnzlSx~TqnWK4oYJCGmNHjYlVbCvmYAFCRc3oFzdywzGQKeQpwqHMhR1DSrEnzMjC48mFyFXyDp5TL1qhMVNUDX~d6Ds6PoysCXV7zG8QawSdWhzwDoj4Gng__&Key-Pair-Id=APKAJSRQXYNPUENHF6HQ&Expires=1387556045"
如果您将rtmp url与我的错误代码进行比较,它会由于某种原因将
src
更改为&
。在这些分号位置,它必须将字符串拆分并将以下值作为不同的flashvar读取。
我怎样才能阻止这一切?
这就是我要构建格式不正确的html:
$(document).ready(function(){
callPlayer("rtmp://s161ki0ys7euuz.cloudfront.net/cfx/st/_definst_/vid_cdntest001?Signature=q-ZT9mWcIorCwGS4xgOysTyRXoUB2yza~JGITwCwx5O0JObgvlvS728vGXaI0iaow4OA8JRdFOBWYeeLQ5klYcjsWtgjzqH37ZVyV-5pyEUgT80DzWOOM9ZVfd2xBaZjISdn4cNk03FRBZ85~Z4zoEkp8MweE2HEzfrHnzZjoXlaulsPuphg59ANZCGQFneGfSI33dYhzTRDnbZbTZAGilLeu8gjtvfgm9hQ80E1zVd7wuHR8hX7or2ZjTgmDBaq4i-Nj8rJI0w3CIKAOu7JBggvclltbDnzMvy76s4Ef~GowYS7GB0p07Whi512GmGB9W1n6TqUBS-m8QK4vvqC~w__&Key-Pair-Id=APKAJSRQXYNPUENHF6HQ&Expires=1387470161");
});
function callPlayer(x){
$("#PlayerHolder").html("<span id='PlayerDiv'></span>");
var flashvars = {
verbose:true,
src: x,
urlIncludesFMSApplicationInstance:true
};
var parameters = {};
var attributes = {};
attributes.name="player";
attributes.id="player";
swfobject.embedSWF("StrobeMediaPlayback.swf?ID="+Math.random()*100,"PlayerDiv","470","320","11.2","scripts/expressInstall.swf", flashvars, parameters, attributes);
}
正确的html由this page生成
最佳答案
显然,这是他们无法解决的问题。is in beta,用户对此不太满意。
解决方案是验证计划发送到flashvars的字符串并转义有问题的字符,如下所示:
$(document).ready(function(){
callPlayer("rtmp://s161ki0ys7euuz.cloudfront.net/cfx/st/_definst_/vid_cdntest001?Signature=q-ZT9mWcIorCwGS4xgOysTyRXoUB2yza~JGITwCwx5O0JObgvlvS728vGXaI0iaow4OA8JRdFOBWYeeLQ5klYcjsWtgjzqH37ZVyV-5pyEUgT80DzWOOM9ZVfd2xBaZjISdn4cNk03FRBZ85~Z4zoEkp8MweE2HEzfrHnzZjoXlaulsPuphg59ANZCGQFneGfSI33dYhzTRDnbZbTZAGilLeu8gjtvfgm9hQ80E1zVd7wuHR8hX7or2ZjTgmDBaq4i-Nj8rJI0w3CIKAOu7JBggvclltbDnzMvy76s4Ef~GowYS7GB0p07Whi512GmGB9W1n6TqUBS-m8QK4vvqC~w__&Key-Pair-Id=APKAJSRQXYNPUENHF6HQ&Expires=1387470161");
});
function callPlayer(x){
$("#PlayerHolder").html("<span id='PlayerDiv'></span>");
x = x.replace(/&/g,'%26');
var flashvars = {
verbose:true,
src: x,
urlIncludesFMSApplicationInstance:true
};
var parameters = {};
var attributes = {};
attributes.name="player";
attributes.id="player";
swfobject.embedSWF("StrobeMediaPlayback.swf?ID="+Math.random()*100,"PlayerDiv","470","320","11.2","scripts/expressInstall.swf", flashvars, parameters, attributes);
}
或者您可以使用非官方的forkbeta,或者直接等到他们修复它。
不过,关于是否应该修复这个问题的争论是相当有趣的。
关于javascript - Swfobject将“&”(与号)更改为“&”如何停止?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20666337/