Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

Developing a site such as the YouTube

What you think about publishing videos in the Web?


Developing a site such as the YouTube


This article examines:

This article uses the following technologies:

       Registering video files in the database;

       Administration and authentication of users;

       Working with Ajax;

       Visualization of videos in the Web;

       Creation of Web User Control.

Visual Studio 2005, ASP.NET 2.0, ASP.NET Ajax and C#.


What you think about publishing videos in the Web? This is a very interesting idea and that has been achieving great success, or have you never speak of the YouTube? If you have never seen it, take a look at The YouTube is a site where we can publish videos and watch any video that is published there. Since it is a site visited in the entire world, the amount of videos is enormous.

Is it too difficult to create a site the same as this one? The answer is no! With ASP.NET 2.0 and SQL Server 2005 (version 2000 and Express will also manage) we will implement, step by step, a site for the publication and the exhibition of videos.

Where to store the videos of the site?

Since we are talking about a gallery, where several people will be able to publish their videos and also watch them, it will be necessary to store the information about the videos (Name of the Video, Description, Author, etc.) in a database.

This is not a problem, but the question that arises following that is: “Where we will store the videos that shall be published?” We have two possible alternatives:

         File System: We can store the videos in a folder of the Web server where the Web site will be published. When the user publishes a video, he will be performing an upload to this folder. And, in the database table, we will store the information of the video and create a field which points to the video stored in the disk;

         Data base: A video, as well as an image or a document, is a set of binary data. The modern databases allow the storage of binary data in their tables. In the SQL Server 2000 we use the image field type and, in the SQL Server 2005, we use varbinary(MAX) for the fields where we store binary data.

But and then? Which of the two kinds is best? Generally, in my articles, I begin already with a practical example, but, before starting, to get hands on, I found it important to raise some advantages and disadvantages of these two kinds of storage so that then we are able to decide which of the two to use.


Advantages of storing binary files in File System

         It demands less work: Through the traditional means, storing and recovering binary data in databases involves a little more work than doing the same in  File System;

         It is easier to generate URLs: So that we may gain access to binary data of a database, we need to create another page to recover the data. To this page we transfer the ID of the record where the file is, and so the file is recovered from the database. We would have a URL similar to this one:




Now if we are storing the files in File System, we will have a much simpler URL:




         Performance: Since the data is being stored in File System of the Web server, instead of being stored in the database, the application is gaining access to less data, reducing the demand and avoiding network congestion between the Web server and the database.

Advantages of storing binary files in the Database

         Better data management: Once the binary data are stored in the database, alongside its metadata (File name, Author, Description, etc.), the management of this data becomes much easier, mainly in tasks such as: backup; transfer from a server database to another; replication, etc.;

         It strengthens the concept of Referential Integrity: When we store a binary file in File System and we create a field in the table that points to the path where this file is, we do not have any referential integrity between the file and the record of the table (any user with rights can erase the file). When storing the file in the database, we have this integrity assured;

         Greater security: When storing binary data in the database, we do not need to give recording rights to the Web User Account in the folder where the files would be stored in File System;

         Version: When storing binary files in the database, we can create version systems, in which, when we upload a new version of the document, the old version is preserved in a different record.  Software such as the SharePoint performs version of the files since they store these in the database.

Our option is...

Watch that the advantages and disadvantages of each of the options are several. It is necessary to evaluate the scenario before making this decision. In our case, we will decide for storing the videos in the database, since the site will be open to any person and we cannot release the access to these users in a folder of the Web server.

We are also making this decision so that we can demonstrate how simple it is to work with binary data in the database when we are using the ASP.NET 2.0 and SQL Server 2005. Anyway, if you do not want to decide for storing binary data in the database, with a few modifications, you will be able to implement the examples of the article by recording the files in File System.

Creating the database

In this example, we will use the SQL Server 2005, but you can use the SQL Server 2000 or the Express version if you wish. Open your SQL Server and create a new database called “WebVideos”. Include a new table called “Videos”, which shall have the same structure demonstrated in Figure 1.


Figure 1. Structure of the table Videos


See that we have a field called VideoData of the type varbinary(MAX). It is in this field that we will store the binary data referring to the video which the user will publish. Also, we have a field called MIMEType, which will store the type of the video which was published.

As we know, there exist various video formats; we will see how to handle this ahead. As for the field VideoId, it was created as identity(1,1). You can check the complete script of creation of the table in Listing 1.


Listing 1. Script for the creation of the table Videos

USE [WebVideos]


/****** Object:  Table [dbo].[Videos]   








CREATE TABLE [dbo].[Videos](

  [VideoId] [int] IDENTITY(1,1) NOT NULL,

  [Title] [varchar](50)

    COLLATE Latin1_General_CI_AS NOT NULL,

  [FileName] [varchar](256)

    COLLATE Latin1_General_CI_AS NOT NULL,

  [Description] [varchar](500)

    COLLATE Latin1_General_CI_AS NOT NULL,

  [Author] [varchar](50)

    COLLATE Latin1_General_CI_AS NOT NULL,

  [MIMEType] [varchar](50)

    COLLATE Latin1_General_CI_AS NOT NULL,

  [VideoData] [varbinary](max) NOT NULL,

  [DateUpload] [datetime] NOT NULL,



  [VideoId] ASC






Preparing the database to use the ASP.NET Membership

Before we begin the Web site in the Visual Studio, we need to decide how we will put the authentication of the users into practice. This is always a delicate decision and that needs to be made at the beginning of the development.

We will decide for using the Login controls of the ASP.NET and, in order to do this, we need to prepare our database so that it contains the tables necessary for the entire control of the Membership of the ASP.NET. For this, execute the aspnet_regsql.exe file, which is in the C:\WINDOWS\Microsoft.NET\Framework\v2.0 .50727 directory.

In the second screen of the wizard, select the option Configure SQL Server for application services. In the following screen, point to the WebVideos database of the SQL Server and proceed with the assistant. When finishing, verify the tables created in the WebVideos (Figure 2).


Figure 2. Tables of the Application Services of the ASP.NET


See that several tables with the aspnet prefix have been created in the database. These tables will be used by the ASP.NET to perform tasks such as control of the users, Roles, Access Rules, Profile etc. We will use these mainly for the process of login of the users thus we will not need to develop anything very complicated. The entire set of features that the ASP.NET provides through these tables is called Application Services.

Creating the WebSite with Ajax

One of the new features for the next articles, starting by this one, is that we will develop the examples using the ASP.NET Ajax. In order to do so, in case it is not yet installed it, it is necessary that you install the Ajax in its development environment.

We will not have time to detail the whole installation of the Ajax, therefore, I ask you to access the site, where you will find the instructions and downloads.

In case you do not wish to use the Ajax in the examples, it is enough not to include the Ajax controls during the development of the application; everything shall function properly. Open the Visual Studio 2005 and choose the option File>New>WebSite. As Figure 3 shows, select the ASP.NET Ajax-Enabled Web Site item; modify the name to “WebVideos” and click upon OK.


Figure 3. Creating a WebSite with ASP.NET Ajax



Done! Now that we already have the Web Site created, we only need to make one small adjustment in the Web.config so that the Login controls of the ASP.NET point to the WebVideos database. Through the Solution Explorer, open the file Web.config.

Observe that the file is much more extensive than normally; this is due to the Ajax which includes several lines of the Web.config. Therefore, it is very important to not modify any of these configurations; we will only include the necessary configurations for the Application Services of the ASP.NET.

With the Web.config opened, search for the tag . Open a line before this tag and include the configurations of Listing 2.


Listing 2. Configuring ConnectionString for access to the WebVideos






      connectionString="Data Source=(local);

     Initial Catalog=WebVideos;

      Integrated Security=True"/>




Watch that we are simply creating a new ConnectionString that points to the database of the application. After that, open a new line, now just below the tag and add the code of Listing 3.


Listing 3. Configuring the MemberShipProvider of the ASP.NET


<authentication mode="Forms"/>













In this second part, we are configuring the authentication mode as Forms, so that we may use the Login controls. And, following, we are configuring AspNetSqlMembershipProvider, which is the provider responsible for the Membership of the ASP.NET.

See that we are pointing to the ConnectionString created previously, in order to assure that the data of the Membership are stored in WebVideos. You may also configure additional information of the Membership or configure other functionalities such as Roles, WebParts or Profiles.

Size of the file

The ASP.NET possesses a standard limit in the size of files for upload, which is 4 MB. To modify this limit, modify the value in the Web.config, adding the following code after the tag :


<httpRuntime maxRequestLength="30000" />


In the previous code, we are limiting the size of the archive in 30 MB. For our application, these configurations are already enough to assure the creation and the authentication of the users.

Creation and authentication of the users

Now, we are ready to create the pages responsible for recording new users and authenticating them it the site. Right click upon the project and choose the option Add New Item. Choose WebForm; modify the name to “NewUser.aspx” and click upon Add.

On the design of this new page we have just created, through the Toolbox, section Login, drag a CreateUserWizard. In the Smart Tag of the control and through the option AutoFormat, modify the layout to Professional.

After that, access the property CancelDestinationPageUrl and type “~/Default.aspx”. Still, in the properties, inform “~/Videos.aspx” in ContinueDestinationPageUrl. Your page shall have to be similar as the one in Figure 4.


Figure 4. Creating the page NewUser.aspx


Return to the page Default.aspx and add a Login control. Modify the layout to Professional and change the property DestinationPageUrl to “~/Videos.aspx”. And, in the properties CreateUserText and CreateUserUrl, respectively inform “New User” and “~/NewUser.aspx”. Your page Default.aspx shall be like the one in Figure 5.


Figure 5. Configuring the page Default.aspx


In order for us to be able to perform a test, create a new page called “Videos.aspx” and place any message in it for the time being. With this done, define the page Default.aspx as Startup Page, save, compile and execute your project.

See that the first page that appears is that of Login. Since we do not have any user in our system, we will create a new one by clicking upon New User. As Figure 6 shows, we were redirected to the page of creation of users.


Figure 6. Creating a new user


Inform the data of a new user and click upon Create User. A message saying that the account was created successfully will appear; just click upon Continue and the page Videos.aspx will be opened.

If you to want to check if the user was correctly created in the database WebVideos, just open the aspnet_Users table. With this, we have ready a system of creation and authentication of users, we can, thus, continue with the development of our application.


Observation: The creation of the password for the provider of the Membership validates some characteristics, such as: size of the password (minimum of seven characters) and must consist of letters, numbers and non alpha-numeric characters.

Typed DataSet

Several techniques exist to create the routines of access and persistence of data. We will decide for the typed DataSet of the ADO.NET, since with it we will gain time and see that the DataSet is widely compatible with tables of the database, which contain fields of the type varbinary(MAX).

Right click on the project and choose the option Add New Item. Choose DataSet; in Name, type “WebVideos.xsd” and click upon Add. In the message that appears, click upon Yes so that the folder App_Code is created in the project, being there where the DataSet will be created.

Cancel the assistant which was initialized. In the Server Explorer, create a new connection with the WebVideos. Expand the connection which you have just created and, in the folder Tables, drag the table Videos to the design of the DataSet. Observe that the DataTable was created with all the fields that we defined (Figure 7).


Figure 7. Creating DataSet WebVideos with DataTable Videos


Click upon the field VideoData and see in the properties that the type of the field is System.Byte[]. This is the type corresponding to the varbinary(MAX) of the SQL Server 2005. There, that is enough for us to be able to proceed.

Publishing a video

Let us now create one of the main functions of the WebSite, the publication of the videos. Open the page Videos.aspx and draw an interface like the one demonstrated in the Figure 8.


Figure 8. Interface for the publication of videos


Before I begin to talk about this interface, see that, in Figure 8, we have a subtitle for you to better identify the controls which were used and their respective properties. Observe that the first control we have is a ScriptManager. This is a control of the Ajax and is necessary in all the pages where we will implement Ajax. Next, we use a LoginName which is used simply to display the name of the user logged into the application.

Below, we include the most important control of the Ajax, the UpdatePanel. The UpdatePanel allows asynchronous calls to the server, avoiding the postback of the page. Watch that the UpdatePanel is a container, where we may include other controls.

Inside the UpdatePanel, we include a Panel in yellow called “pnlNewVideo”.Inside the Panel a table was added where we set up a form for the publication of the videos. In the form, we used two TextBoxes and one FileUpload, which will be used for the uploading of the video. Still, inside the Panel, a Button was added, called “btnPublish”.

An important observation is that the FileUpload, obligatorily, needs a postback so that the selected file may be sent to the server. Therefore, we need to make it so as for the button, although in the UpdatePanel, performs the postback.

For this, click upon the UpdatePanel1 and access the property Triggers. Watch, as Figure 9 shows, that in the window of Triggers we may configure controls to perform asynchronous calls (AsyncPostBackTrigger) or PostBacks (PostBackTrigger).


Figure 9. Creating a PostBackTrigger in the UpdatePanel


In our case, we will create a PostBack trigger for the btnPublish, so that the file selected in the FileUpload is sent to the server when we click on the button. Apart from the controls we have just seen, the rest is tables and text. Configure the properties indicated in the figure and save your page.

We will now include the code needed to perform the publication of the videos. First, in the code of the page Videos.aspx, we shall include, in the namespaces region, the following line:


using WebVideosTableAdapters;


This is the namespace where we have the TableAdapter which contains the methods of persistence and access to the data of the table Videos. Next, return to the interface of the page, double click on the button and add the code in Listing 4.


Listing 4. Code for the Publication of the Videos

protected void btnPublish_Click(object sender,

  EventArgs e)


   if (txtTitle.Text.Trim() == string.Empty)


      Response.Write(" window.alert("+

"'Title is required!'); ");


   else if (!FileUpload1.HasFile)


      Response.Write(" window.alert("+

"'Is necessary to select a video!'); ");




      string extension = System.IO.Path.GetExtension(


     string MIMEType = "";

     switch (extension)


         case ".avi":

           MIMEType = "video/avi";


         case ".wmv":

           MIMEType = "video/x-ms-wmv";



           Response.Write(" window.alert("+

"'Invalid file type!'); ");



      if (MIMEType.Trim() != string.Empty)




            VideosTableAdapter adapter = new




              txtDescription.Text, User.Identity.Name,

              MIMEType, FileUpload1.FileBytes,


            Response.Write(" window.alert("+

"'Publication finished!'); ");


         catch (Exception ex)


            Response.Write(" window.alert('" +

ex.ToString() + "'); ");


         txtTitle.Text = "";

         txtDescription.Text = "";





We will now see what this code does. First, observe that we are checking if the title of the video was informed. In case it has not, we are informing (through Javascript) in a MessageBox, a warning to the user. Watch that we are making a very simple validation of the form; you can implement the validation in the manner you think is the best.

After that, through the property HasFile of the FileUpload, we can identify if the user has selected a file. In case he has not selected, we are, again, printing a warning message.

In case the user has informed the title and chosen the file, our next step is to identify and to validate the type of this file, using the MIMEType. MIMEType or Internet Measured Type is a standard of the Internet used to classify types and subtypes of files. Greater details and a list of the most common types, you may find in the wikipedia:

MIMEType, although not obligatory, is important for a correct classification, and the posterior rendering of the videos, therefore, we must store the correct MIMEType of the videos which will be published. The easiest way to identify the MIMEType is through the file extension.

Through the GetExtension of the class Path, we can recover the extension of a file. In our case, we are doing this with the FileName property which loads the name of the selected file in the FileUpload.

Following, through a switch structure, we validate the possible MIMETypes. In this example, we are only checking the video/avi (AVI) and video/x-ms-wmv (WMV) types. This means that the application will only accept videos with these extensions. In case you want to include other types of videos, it is enough to include the verification of that extension and to store the correspondent MIMEType.

Proceeding with the code, in case the user has selected one of the file types supported by the application, we are creating a new instance of the class VideoTableAdapter and calling the Insert for the inclusion of the record in the table Videos. See that the second last parameter of the method is an Array of bytes (bytes[]), where we are passing the property FileBytes of the FileUpload, which has  the complete binary of the file selected by the user.

And there you are, with this we have the publication routine of the videos ready, remembering that the video will be stored in the table Videos, alongside with its additional data. Shall we run a test? Save, compile and run the application.

In the login screen, inform the user and password that we have registered previously and click upon Login. As is shown by Figure 10, fill the data of the video and select a video file with an AVI or WMV extension.

Next, click upon Publish. After the conclusion of the publication, you will receive a confirmation message. In order to verify that, take a look at the table Videos in the SQL Server, notice that the video was correctly included.


Figure 10. Testing the publication of videos


Creating a query for the videos

The next step is simple, just list the videos published in a GridView. We will include the new controls in the page Videos.aspx itself. For this, take a look at Figure 11.


Figure 11. Interface for the consultation of the videos in GridView


First, add an UpdatePanel to the cell below of the one in which we have drawn the publication interface. Inside the UpdatePanel, includes an ObjectDataSource, which you can find in the section Data of the Toolbox. Click upon the task Configure Data Source, in the first screen of the wizard, select the VideoTableAdapter and click upon Next. After that, it is enough to click upon Finish.

Drag a GridView below the ObjectDataSource. In the tasks of the GridView, in Choose Data Source, choose ObjectDataSource1. Still in the tasks of the GridView, select the option Enable Selection and click upon Edit Columns. In the Selected Fields area, you shall exclude the FileName and Description columns. In order to complete the configurations of the GridView, through the option AutoFormat, choose Simple.

Now we only need to include one code line to update the GridView every time that a new video is published. For this, in the click event of the Publish, just below the line txtDescription.Text = “”; include the following code line:




Let us run a test? Save, compile and run the project. Make the login and see, as Figure 12 shows, that the description of all the published videos is already appearing. Publish a new video and see that it is automatically included in the GridView.


Figure 12. Testing the query of the videos


Customizing TableAdapter to recover the video

As we have seen in the beginning of the article, you cannot access a file which is inside the database, as if it was inside the File System. In order to do that, we need to create a page which will receive the video ID as parameter and then recapture the file. Thus, we will be able to access the video through a URL.

First, we need to have a method in the TableAdapter which, through the ID, returns only the binary file; for that, we must customize the TableAdapter for the inclusion of this new method. In the folder App_Code, open the DataSet WebVideos.xsd and, as Figure 13 shows, right click over the VideosTableAdapter and choose the option AddQuery.


Figure 13. Including a new query in the TableAdapter


In the first screen of the wizard, choose the Use SQL statements option and click upon Next. In the following screen, choose SELECT which returns a single value, for we will return only the binaries of the video. In the next screen, type the following SELECT command:


SELECT VideoData FROM Videos WHERE VideoId = @VideoId


After that, click upon Next. In the following screen, inform “SelectVideoData” as the name of the method which will be created. Click upon Next and upon Finish. See that in the TableAdapter a new method has been created and will be used to recover the binaries of the video from the table Videos.

Creating the page to return the video

Now we need to create a page which will receive the ID of the video as a parameter and recover the binaries from the database. Right click upon the project and choose the option Add New Item. Select the item Web Form, type “ShowVideo.aspx” in Name and click upon Add.

We do not need to include anything in the interface of this page. Go to the page code and modify it so that it becomes like the one demonstrated in Listing 5.


Listing 5. Code of the page ShowVideo.aspx


using WebVideosTableAdapters;


public partial class ShowVideo : System.Web.UI.Page


    protected void Page_Load(object sender,

      EventArgs e)


        int VideoID = int.Parse(


        string MIMEType = Request.QueryString[


        VideosTableAdapter adapter = new


        byte[] VideoData =


        if (VideoData.Length > 0)


            Response.ContentType = MIMEType;






First, you will have to include a reference to the WebVideosTableAdapters namespace. After that, see that we are using only the Page_Load, where, through a QueryString, we are recovering the two parameters which will be informed in the URL: the VideoId and the MIMEType.

After that, through the SelectVideoData which we created in the TableAdapter, we are recovering the database file, which will be stored in an object byte[]. To finish, in case the VideoData is not empty, through the Page.Response, we are configuring MIMEType and “displaying” the file through the BinaryWrite.

This page enables access to the videos of the database, through a URL. Like, for example, the URL to access the video which number is 1, would be like this:




If you wish to run a test, type that URL in your browser (in case you have published the video which number is 1, with the WMV extension). What happened? The browser called the Windows Media Player and executed the video.

Displaying the videos inside the page

This is a way of recovering the videos of the database, but not the ideal one. The ideal would be to display the videos inside our page Videos.aspx, like it is done in the YouTube site. Unfortunately, the ASP.NET does not have a control that performs this task; for that, the HTML itself has some solutions. One of them, and the most used, is the tag <object>.

We will run a simple test. Open the page Videos.aspx and, in the cell on the right side, which is empty, include a new UpdatePanel. Go to the Source of the page and search for the UpdatePanel3, which we have just finished including. Inside it, you will have to insert the code of Listing 6.


Listing 6. Displaying video through the Object command


<asp:UpdatePanel ID="UpdatePanel3" runat="server">


<object id="Player"


 <param name="autoStart" value="True"> 

  <param name="URL"


 <param name="rate" value="1">

  <param name="balance" value="0">

  <param name="enabled" value="true">

  <param name="enabledContextMenu" value="true">

  <param name="fullScreen" value="false">

  <param name="playCount" value="1">

  <param name="volume" value="100">






See that the tag will use the Windows Media Player itself to display the video inside the page, in the space where we included the UpdatePanel. Observe that we have several parameters which can be configured.

Amongst them, the most important one is the parameter URL, where we are pointing to the ShowVideo.aspx page, passing the VideoId=1 as parameter. Run a test, save, compile and run the project. See that now the video will be displayed inside the page.

Creating a WebUserControl to display the video

Very well, but how to get the video selected in the GridView to be displayed? Customizing a little bit the previous code, we may be able to set up and recover the URL according to the record selected in the Grid. However, I do not know what you think, but I do not like to have an HTML code inside an ASP.NET page. Apart from being hard to give maintenance to, it is not a solution which is easily reusable.

A much more graceful solution would be the creation of a WebUserControl, which would be responsible for rendering the HTML code necessary for the displaying of the video. Shall we try? Right click over the project and choose the option Add New Item. Choose the item Web User Control; inform “VideoPlayer.ascx” in Name and click upon Add.

We will not include anything in the interface of the control, therefore, just press F7 to go to the code. After that, modify the code so that it becomes just like the one demonstrated in Listing 7.


Listing 7. Code of the control VideoPlayer.ascx


using System.Text;


public partial class VideoPlayer :



    private string _Url = "";

    public string Url


        get { return _Url; }

        set { _Url = value; }



    protected override void Render(

      HtmlTextWriter output)


        StringBuilder sb = new StringBuilder(

          " + this.ClientID +

+ _Url + "'> "' name='"+ this.ClientID + "' " +

          "CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'" +

          "height=300 width=300>");

























Watch that the System.Text namespace was imported, so that the use of the StringBuilder is possible. After that, we are creating an attribute called _URL and its respective property called Url. Observe that we do not need the Page_Load and we are overloading the Render, which is responsible for rendering the control in the page.

Inside the Render, through a StringBuilder we are setting up a string which corresponds to the HTML code that we have used previously to display the video. The difference is that, here, the parameter URL is not fixed; it will be recovered from the property URL. At the end, the output.Write needs to be called so that the HTML is rendered.

Save the control and return to the page Videos.aspx. Erase the HTML code which was inserted in the previous example, and return to the design of the page. Through the Solution Explorer itself, drag the VideoPlayer.ascx inside the UpdatePanel3 (Figure 14).


Figure 14. Including the VideoPlayer.ascx in the page Videos.aspx


Having done this, we have to include the code necessary to change the URL of the control according to the video which is selected in the GridView. Click upon the GridView and access the event SelectedIndexChanging. Now, it is enough to include the code in Listing 8.


Listing 8. Event SelectedIndexChanging of the GridView

protected void GridView1_SelectedIndexChanging(

  object sender, GridViewSelectEventArgs e)


int VideoId = int.Parse(GridView1.Rows[


      string MIMEType = GridView1.Rows[


      VideoPlayer1.Url = "ShowVideo.aspx?VideoId=" +

        VideoId.ToString() + "&MIMEType=" +




In this code, we are recovering the ID and the MIMEType of the video which was selected and, following, setting up the URL to access the video, already storing it in the very own property Url of the VideoPlayer1. Much better to work like this than with HTML, don’t you think?

Let us run a test. Save, compile and run the project. See, as Figure 15 shows, that it is enough to click upon the link Select of any video, so that it will be displayed in the right side. Conduct the test with several videos. Another thing you can observe is that, since we are using Ajax, there is no postback when we select the video.


Figure 15. Testing the displaying of videos with the VideoPlayer.ascx



As we have been able to see, it is very simple to create an application to store and visualize videos in the Web. We have seen that there is no great difficulty in storing files in the database, especially when we are working with Typed DataSets and TableAdapters.

With the use of the Ajax and the Web User Control, we have also seen how simple it is to create an interface for publication and displaying of videos in the Web. However, our application is very far from being a YouTube.

I will now list a few functionalities which you may include in this application so that it heeds other needs of a video gallery:

         Options of search: Our example, lists all the published videos in one GridView, which would be impracticable in a real application, where many videos would be published. We would have that to make available search options so that the user can look for the videos which he desires, by name, date, description, etc. And, also, create queries such as, for example: the ten most seen videos. Customizing some methods of the TableAdapter, we can easily implement these and other functionalities of search;

         Categorization of the videos: A very important option that the site must have is the categorization of the videos. It would be enough to create a table of categories, relate it with the table of videos and request this information at the moment of the publication of the video. A more advanced option would be a process of automatic categorization of the videos, but this would involve complex routines of analysis of the texts Title and Description, to categorize the videos automatically;

         Administrative Interface: It would be interesting that the site had an administrative area, where administrator users of the site can log in and modify information to which the final users do not have permission;

         More properties of the VideoPlayer.ascx: As we have seen, we use the WebUserControl to be able to abstract the use of HTML in a user control. With this, we gain the possibility of determining the URL of the control through a property. We could extend this functionality to other properties of the control such as, for example: Width, Height, AutoStart, volume, etc.;

         To not depend on the Windows Media Player: Despite us displaying the video in the Web, the tag uses the Windows Media Player itself to display the video. This means that the final user needs to have the Windows Media Player installed in his computer. Obviously, you can use any other Player that you wish, just reference the correspondent ClassID. A more advanced solution for this problem would be the creation of your own video Player, but then, that is another talk.

I hope that this article may have helped you understand all the techniques involved in the development of an application which stores videos in a database and displays them in the Web. Cheers to all and see you next time.



Site of the Youtube

Site of the Ajax

Definition of MIME Type of the Wikipedia

colunista nao disponivel

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login