[ASP. NET Control for day12] inherits tbactivex and rewrites the tbmediaplayer Control

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.