03-05-2013, 04:07 PM
Display Video using a C# Web Custom Control
Display Video.doc (Size: 859.5 KB / Downloads: 17)
Introduction
This article shall describe the construction of a custom control used to play video on an ASP.NET web page. The control is based upon the Windows Media Player active X control; with it you can add canned or live video to a web page by setting a property or two at design time, or from the ASP.NET page itself. The demonstration project will show a couple of ways in which the control may be used in an ASP.NET web application.
The Solution
The solution contains two projects; the first is the web custom control and the seconds is a sample web site with two pages, each displaying the controls in use to display video. The control project is called “WebVideo”; it contains a single web custom control called, “WVC”. The demonstration website contained in the second project is called, “TestWVC”. The website contains to web pages called “Default” and “WebCams”.
The Code: Web Video – WVC Custom Control
The WVC custom control project is a web custom control project; it contains only a single control (WVC). This control wraps up the media player control and provides design time support for the control through a collection of properties used to set some of the various properties used by the media player control.
The only reference added to the project, aside from the defaults, was System.Design. System.Design is necessary to support some of the design time functionality exposed by the control such as using the URL editor with the file path property of the control.
The Code: Test Web WVC
The demonstration web project is comprised of two web pages; one page, the default, demonstrates a single contro in use. It also uses a drop down list control set to auto postback; the list contains a set of items with the value property pointing to a valid source of media. When the drop down list is used, the media player’s file path is set to point to the new source of media. The second page contains four controls each set to a different source and with the control panel options enabled. The code is trivial and is not reported in this document.