我正在尝试创建一个嵌入了银色视频的javascript,但是当我把它放在网页上时,它不起作用。
<div id="silverlightControlHost"></div>
<script type="text/javascript">
Silverlight.createObject(
"myvideo.3gp", //video
document.getElementById('silverlightControlHost'), // parent
"slPlugin", // id for generated Silverlight object
{
width: "400", height: "100", background: "#CCCCCC"
}, // property values of the silverlight object
{ }, // event handlers (optional)
"param1=value1,param2=value2", //extra params (optional)
"context" // context (optional)
);
</script>
答案 0 :(得分:1)
我们在NimbusHD执行此操作;对于嵌入式播放器示例,请转到www.nimbushd.com&gt;观看视频。
我不会使用Silverlight.createObject()方法......只需直接写出<object>
标记。
<script type="text/javascript" src="http://play.nimbushd.com/Silverlight.js"></script>
<script type="text/javascript">
function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
appSource = sender.getHost().Source;
}
var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;
if (errorType == "ImageError" || errorType == "MediaError") {
return;
}
var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";
errMsg += "Code: " + iErrorCode + " \n";
errMsg += "Category: " + errorType + " \n";
errMsg += "Message: " + args.ErrorMessage + " \n";
if (errorType == "ParserError") {
errMsg += "File: " + args.xamlFile + " \n";
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
else if (errorType == "RuntimeError") {
if (args.lineNumber != 0) {
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
errMsg += "MethodName: " + args.methodName + " \n";
}
throw new Error(errMsg);
}
</script>
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="480" style="z-index: -1;">
<param name="source" value="/path/to/my/silverlightApp.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<param name="Windowless" value="true" />
<param name="initParams" value="" />
<div>You don't have Silverlight installed</div>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>