Published: 20 Oct 2011
By: Xianzhong Zhu
Download Sample Code

In this series of articles, we'll try to build a popular YouTube-like video playing website using ASP.NET related techniques.

Contents [hide]

Introduction

In this series of articles, we'll try to build a popular YouTube-like video playing website using ASP.NET related techniques. After you read this series, you may draw such a conclusion: so simple to construct my own video playing website! But wait a moment: you should have to grasp the necessary ASP.NET fundamentals. In another word, this series will involve quite a few ASP.NET techniques, such as C# programming tips, Microsoft SQL Server 2008, ASP.NET AJAX server-side modules, browser-side Flash player, Internet Information Server, and so forth.

NOTE

The development environments in the sample project will involve:

1. Windows XP Professional (SP3);

2. .NET 3.5 (SP1);

3. Visual Studio 2008 Professional (SP1);

4. Microsoft SQL Server 2008.

Development Background

With the rapid development of Internet, showing self-expression by text is no longer a mainstream. Podcasting sites, e.g. the famous youtube.com, are welcomed by the majority of users who try to show themselves through video displays. Facts speak louder than eloquence. Millions of videos are uploaded to the podcast sites and the online video watching or clicking times can exceed a million times. Some people can submit their videos to the podcast sites, while others can watch these videos and make comments upon them, which in a great degree helps to enhance communication between users. And on the other hand, a successful video site will bring huge business profits to site owners.

Requirement Analysis

For a long time, people's video made by themselves can only be stored in their computers. If they want to share these wonderful homemade videos with friends and family, they have to resort to some traditional methods (such as burning CDs, etc.) and mail it to them, consuming time and laborious. If we can develop some video site, you can upload and share video to a friend, it would be a pleasure for everyone to share the process.

Due to the above demand, the more welcomed podcast websites appear. Podcasting network is a platform which can assist users to show themselves through their published various forms of videos. In a podcast network, users can be registered as a member of the site, and then they can publish their own videos to the site. Other users can enjoy these videos released by the site members; and also, they can even express their views or opinions towards the products.

In addition, podcast sites can also provide point ranking functionalities. For example, the more a member posts videos, the higher points he can obtain. The site's backend administration module can manage the videos via various kinds of policies. Members' released videos must be reviewed by an administrator before they can be displayed in the front page. If a member has posted the offending video, the administrator has the right to freeze the account.

System Design

Now, let's start from the system design phase. First, look at the system target.

System target

An ideal video site should at least achieve the following objectives:

  • User-friendly and beautiful interface, safe and reliable data storage.
  • Ordinary users can watch the videos by category, such as jokes, sports, and so on.
  • Powerful video search capabilities, to ensure the flexibility of video queries.
  • Ordinary users and members can both make comments on the videos.
  • Member points management. The more products a member of the video site uploads, the higher the points he can receive.
  • Video legality audit support. If a member is found to publish illegal videos, the administrator can use this function to freeze his account.
  • Video ranking support mainly based on video hit rates.
  • Personal management center. Users can manage their own uploaded videos.
  • The system administrator can control the video ranking, the site's dynamical advertisements, as well as recycling playing arrangement.
  • Maximize the maintenance and operability.

Business flow chart

To give a more intuitive understanding with the video playing website, let's first depict the business flow chart of the system using graphics.

Figure 1: Business flow chart of the system

Business flow chart of the system

Backend system functionalities structure

According to the audit characteristics of a podcasting site, we can design the basic backend administrator audit functionalities structure, as shown in Figure 2.

Figure 2: Backend system administrator audit functionalities architecture

Backend system administrator audit functionalities architecture

Database Design

In this system, the database is named playVideo designed using SQL Server 2008. There are eight tables contained in the database playVideo. For the readers to gain a clearer idea of the database design, we'll give to you both the graphical E-R representation and the table structure details.

Database conceptual design

According to the preceding requirement analysis, system flow chart introduction, and system functionality structure, we can easily design the main database entity objects used by the system.

As explained above, after the registered members publish their videos, the administrator needs to audit the video contents and all related info in the backend management. If illegal, then these videos will be refused. The video detailed info related E-R diagram is given in Figure 3 below.

Figure 3: Video detailed info related E-R diagram

Video detailed info related E-R diagram

Obviously, without users' comments even seemingly-wonderful videos will be eclipsed. We can also easily design the video comment info related E-R diagram, as shown in Figure 4.

Figure 4: Video comment info related E-R diagram

Video comment info related E-R diagram

After the splendid videos get recommended by surfers, the degree of concern will be greatly enhanced. The video ranking info related E-R diagram is given in Figure 5.

Figure 5: Video ranking info related E-R diagram

Video ranking info related E-R diagram

If good videos can be found and recommended by users, we can exhibit the related info by setting up some video voting module. The video poll info related E-R diagram is shown in Figure 6.

Figure 6: Video poll info related E-R diagram

Video poll info related E-R diagram

Database Logical structure design

Now that the database E-R diagrams has been introduced, the next task should be designing the related tables according to the existing E-R info.

Now, let's look at the detailed table structure definitions. The first one is table userRegister.

Table 1: Structure for table ‘userRegister’

Field name

Type

Nullable

Note

ID

int

No

Auto incremental ID

userName

varchar

Yes

User login name

userPass

varchar

Yes

User password

useQuestion

varchar

Yes

Password related question

passAnswer

varchar

Yes

Password prompt answer

email

varchar

Yes

Email address

lock

bit

Yes

Whether this user has been locked

lockCause

varchar

Yes

The locking cause

Table VideoInfo contains all the video info that users upload. Below is the structure for table VideoInfo.

Table 2: Structure for table ‘VideoInfo’

Field name

Type

Nullable

Note

ID

int

No

Auto incremental ID

userName

varchar

Yes

User's login name

videoTitle

varchar

Yes

Video title

videoContent

varchar

Yes

Video content

videoDate

varchar

Yes

Video publishing datetime

videoPath

varchar

Yes

Video path

videoPicture

varchar

Yes

Video picture related path

videoType

char

Yes

Video type

playSum

int

Yes

Overall video hit rate

flower

int

Yes

The number of users who like the video

tile

int

Yes

The number of users who dislike the video

monthSum

int

Yes

Hit rate in this month

Auditing

bit

Yes

Audit state

Table VideoIdea is used to hold all video related comment info of customers. Below gives the structure for this table.

Table 3: Structure for table ‘VideoIdea’

Field name

Type

Nullable

Note

ID

int

No

Auto incremental ID

userName

varchar

Yes

Customers who make comments

content

text

Yes

Comment content

videoId

int

Yes

Commented video's ID

issuanceDate

datetime

Yes

Comment making datetime

Table VideoTaxis contains all ranking info of videos per month. Below indicates the structure for this table.

Table 4: Structure for table ‘VideoTaxis’

Field name

Type

Nullable

Note

videoId

int

No

Video code

videoType

char

Yes

Video type

videoTitle

varchar

Yes

Video name

playSum

int

Yes

Video hit rate

taxisMonth

char

Yes

Video ranking per month

Table VideoPoll is used to hold all polled user IP and video Id. Below indicates the structure for this table.

Table 5: Structure for table ‘VideoPoll’

Field name

Type

Nullable

Note

ID

Int

No

Auto incremental ID

IP

varchar

Yes

Voter's IP

videoId

int

Yes

Voter's video ID

Table bulletin contains the bulletin related info. Below indicates the structure for this table.

Table 6: Structure for table ‘bulletin’

Field name

Type

Nullable

Note

ID

int

No

Auto incremental ID

Title

varchar

Yes

Bulletin title

content

varchar

Yes

Bulletin content

issuanceDate

datetime

Yes

Bulletin issue datetime

There are still two tables left, manageUser and userInfo. Since they are commonly-seen user info management related ones; we'll no more list them.

Design Common Classes

To improve development efficiency and facilitate future maintenance, some common helper classes are necessary to a good-shaped application. In our case, we've written two helper classes located under the folder App_Code. The first helper class is named operateData, which aims to ease ordinary database operations. The second helper class is operateMethod, inside which there are hidden several methods commonly-used somewhere in the application.

The Helper Class operateData

The first important method defined in the class operateData is execSql. This method is used to execute record add, insert, and update operations with the tables. It returns a bool type to indicate whether the current operation is successful or not. The only argument passed into the method is a typical SQL string which specifies the target table operation.

Another method worth noticing is getTier, which is used to return specified column related value. The only argument passed into the method is also a SQL string to decide the corresponding operation. It returns a string type to indicate the returned value.

The third method defined in the helper class operateData is getRows. As the name implies, this method will return all the data in the target table. But note that this method returns a DataTable object, with only an argument passed in to give the required SQL operation.

Another method to take notice of is login. This method is used to check whether the current user has successfully logged in or not. The returned value True indicates login success, while False shows failure.

Above we've used SqlCommand.Parameters to filter out the illegal characters to prevent from the notorious SQL injection attack.

Now, let's research into another helper class operateMethod.

The Helper Class operateMethod

There are some important methods which deserves your attention. The first one is called changeVideoType, which is responsible to transform the users' uploaded videos into the .flv format and then store them under corresponding folders. There are three arguments: the first one specifies the file to transform, the second corresponds to the transformed file, and the third is used to store the video capturing file.

NOTE

FFmpeg.exe is a complete, cross-platform solution to record, convert and stream audio and video. FFmpeg.exe is free software licensed under the LGPL or GPL. It includes libavcodec - the leading audio/video codec library. In our case, you can easily convert your popular .wmv and .avi files into .flv files to play in the client-side Flash player embedded in various browsers. And also, FFmpeg.exe can be easily used to achieve the target of capturing .flv interfaces into static images (see the subsequent method catchImg). For all details concerning FFmpeg, especially your interested parameters, you can refer to the site http://ffmpeg.mplayerhq.hu/.

As mention in the above method, our system provides the function of video capturing. This is achieved through the method catchImg. There are two arguments passed into this method: the first specifies the file whose video will be captured, the second corresponds to the file to hold the captured image.

Another method commonly used in web site programming is named filtrateHtml, which is used to transform some invalid characters into valid ones that can be identified by the backend system.

The corresponding method whose function is opposite to the above method is named resumeHtml, as follows.

Summary

In this first part of the series, you've learned the background to build a video site. Then we made simple requirement analysis and made clear the design target. And next, you got familiar with the business flow chart of our sample system, as well as the system functionality architecture. Then, we introduced the sample database named playVideo, which contains eight tables. And finally, we introduced two fundamental coding helper classes, operateData and operateMethod, which will help to greatly simplify the development and later maintenance of the system. Starting from the next part, we'll dive into the concrete web page design.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Xianzhong Zhu

I'm a college teacher and also a freelance developer and writer from WeiFang China, with more than fourteen years of experience in design, and development of various kinds of products and applications on Windows platform. My expertise is in Visual C++/Basic/C#, SQL Server 2000/2005/2008, PHP+MyS...

This author has published 81 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category


Code First Approach using Entity Framework 4.1, Inversion of Control, Unity Framework, Repository and Unit of Work Patterns, and MVC3 Razor View
A detailed introduction about the code first approach using Entity Framework 4.1, Inversion of Contr...
jQuery Mobile ListView
In this article, we're going to look at what JQuery Mobile uses to represent lists, and how capable ...
Exception Handling and .Net (A practical approach)
Error Handling has always been crucial for an application in a number of ways. It may affect the exe...
JQuery Mobile Widgets Overview
An overview of widgets in jQuery Mobile.
Book Review: SignalR: Real-time Application Development
A book review of SignalR by Simone.

You might also be interested in the following related blog posts


GiveCamps Get a new Sponsor read more
VideoWicki A Open-Book Design-To-Delivery Silverlight 3 Project read more
Script for Bulk Import of Active Directory Site Links read more
Script for Bulk Import of Active Directory Subnets read more
Adding QueryString Parameters to the SiteMapNode read more
Party with Palermo @ DevTeach is tomorrow!! read more
ASP.NET Menu and SiteMap Security Trimming (plus a trick for when your menu and security don't match up) read more
ASP.NET 3.5 Extensions CTP Preview Released read more
Popfly beta read more
CardSpace: How Personal Cards Protect Users read more
Top
 
 
 

Discussion


Subject Author Date
placeholder great Mike Garret 11/4/2011 7:53 AM
Problem Shakti Singh 4/4/2012 6:03 AM
placeholder Building a YouTube-like Video Playing Site Moataz Zulfecar 7/21/2013 3:21 PM

Please login to rate or to leave a comment.