The tbactivex control introduced in the previous article. It supports the setting of media player on the webpage, which is the same as the tbmediaplayer function mentioned above. Tbmediaplayer can be inherited by tbactivex and added to the attributes unique to media player. In this article, the original tbmediaplayer control is changed from webcontrol to tbactivex, And the tbmediaplayer control is rewritten.
ProgramCodeDownload: ASP. NET Server Control-day12.rar
I. Rewrite TbmediaplayerWidget
The tbmediaplayer control was originally inherited from webcontrol, and now the inherited object is tbactivex to rewrite the tbmediaplayer control.
Step1. tbmediaplayerInherit Tbactivex
Added the tbmediaplayer control, inherited to tbactivex, and set the classid of Media Player ActiveX in the constructor.
Public ClassTbmediaplayer
InheritsTbactivex
''' <Summary>
'''Constructor.
''' </Summary>
Sub New()
Mybase. Classid ="6bf52a52-394a-11d3-b153-00c04f79faa6"
End Sub
EndClass
Step2.Add related attributes
Like the original tbmediaplayer control, add the URL, autostart, and uimode attributes, and add the attributes to be set as needed.
Step3.Join Media PlayerParameters
Override the createchildcontrols method and dynamically add parameters to the Params set attributes according to the attribute settings. Although tbmediaplayer controls only the URL, autostart, and uimode attributes before the project, the parent class tbactivex has the Params set attribute, so developers can add other undefined parameters as needed.
''' <Summary>
''' Adds mediaplayer metrics.
''' </Summary>
''' <Param name = "name"> parameter data. </Param>
''' <Param name = "value"> numeric value. </Param>
Private SubAddparam (ByvalNameAs String,ByvalValueAs String)
DimOparamAsTbactivexparam
Oparam =NewTbactivexparam (name, value)
Me. Params. Add (oparam)
End Sub
''' <Summary>
''' Override the createchildcontrols method.
''' </Summary>
Protected Overrides SubCreatechildcontrols ()
'Add URL parameters
If Me. Url <>String. EmptyThen
Addparam ("Url",Me. Resolveclienturl (Me. Url ))
End If
'Add autostart vertex data
If Me. AutostartThen
Addparam ("Autostart","True")
End If
'Add the uimode parameter number
If Me. Uimode <> euimode. notsetThen
Addparam ("Uimode",Me. Uimode. tostring)
End If
Mybase. Createchildcontrols ()
EndSub
Ii. execution procedure
Drag the tbmediaplayer control on the page to set the URL, autostart, and uimode attributes. If you need to add other parameters, you can set the Params set attributes on your own. Execute the program to view the rendered media player on the page.
<Bee: tbmediaplayer ID= "Tbmediaplayer1" Runat= "Server" Autostart= "True"
Height= "249px" URL= "D: \ movie_01.wmv" Width= "250px">
</Bee: tbmediaplayer>
Note: This article is also published in "the first it state help tie Ren Competition". If you think this articleArticleIt is helpful to you. Remember to add popularity when you connect to this article ^
Http://ithelp.ithome.com.tw/question/10012196