我想将Windows Media Player嵌入到我的ASP.NET页面中。我使用此代码执行此操作,该工作正常:
<OBJECT id='mediaPlayer1' width="180" height="50"
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
<param name='fileName' value="http..">
<param name='animationatStart' value='true'>
<param name='transparentatStart' value='true'>
<param name='autoStart' value="false">
<param name='showControls' value="true">
<param name ="ShowAudioControls"value="true">
<param name="ShowStatusBar" value="true">
<param name='loop' value="false">
<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="420" height="380"
src="http..."
autostart="true" designtimesp='5311' loop="false">
</EMBED>
</OBJECT>
我的问题是,我想更改后面代码中的url(如here,但它是在VB中,而不是C#),因为我从数据库中加载了Urls。那么有没有办法,我可以在我的c#部分中添加此代码,或者更好 - 从c#部分访问网址?
很抱歉,如果这是一个愚蠢的问题,但我现在搜索了几个小时..和this.FindControl(mediaPlayer1);不起作用。
答案 0 :(得分:2)
覆盖Render
方法
编辑它以满足您的要求。
protected override void Render(HtmlTextWriter writer)
{
StringBuilder stringBuilder = new StringBuilder("<OBJECT "
+"ID='" +this.ClientID + "' "
+ "name='" + this.ClientID + "' "
+"CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'"
+"VIEWASTEXT"
);
stringBuilder.Append("<PARAM name='autostart' value='false'>");
stringBuilder.Append("<PARAM name='autoplay' value='false'>");
stringBuilder.Append("<PARAM name='URL' value='/" + fileUrl + "/" + selectedFile + "'>");
stringBuilder.Append("<PARAM name='rate' value='1'>");
stringBuilder.Append("<PARAM name='balance' value='0'>");
stringBuilder.Append("<PARAM name='enabled' value='true'>");
stringBuilder.Append("<PARAM name='enabledContextMenu' value='true'>");
stringBuilder.Append("<PARAM name='fullScreen' value='false'>");
stringBuilder.Append("<PARAM name='playCount' value='1'>");
stringBuilder.Append("<PARAM name='volume' value='100'>");
stringBuilder.Append("</OBJECT>");
divWindowsMediaPlayer.InnerHtml = stringBuilder.ToString();
base.Render(writer);
}
答案 1 :(得分:0)
好的,当然已经有一个答案,我昨天没有看到4个小时,但是今天早上......:Using Object tags in asp.net