DEVELOPING MY OWN LIFE.

Arrowat: https://arrowat.com/melvin Facebook: https://www.facebook.com/melvindev Youtube: https://www.youtube.com/melvindev Twitter: https://twitter.com/melvindevdotcom Instagram: https://www.instagram.com/melvindevdotcom LinkedIn: https://www.linkedin.com/in/melvindevdotcom

YouTubeTv OpenSource Library For C# Net and VB.Net

On This Page

YouTubeTv library allows you to manipulate a Youtube URL, extracts the Video id and the default image from video , and the video URL ready to play in iframe

Note: It does not use any API or third party library this is an opensource library you can download it from Github at https://github.com/melvindev/YouTubeTv

Youtubetv Works on C# and VB.Net and can be used on ASP.Net web applications and Windows Applications, There are samples added with downloaded source code.

See a Sample

YouTubeTv library How to:

This is a Class library, you can start adding reference to your project or if you don't have it separated as a DLL you can copy all project code contained on the project available from Github Site at : https://github.com/melvindev/YouTubeTv Please check the code sample, I have added a Project test Named 'YouTubeTvtest' that you can guide how to code your own.
If you decide to create your own project you will need to add reference to YoutubeTv.dll that contains the source code compiled on a single file.

YouTubeTvProjects

You can explore all code from theYouTube library, Let's start checking the library functions and properties

Dowload YouTubeTv from Github

DectectURL Class Members

IsValidURL()

This function helps you to check if the YouTube URL is Valid , Returns True if the URL is valid and False if the URL is Invalid

DetectURLLInk()

This Function helps you to detect a URL between text, it takes the first URL out from any text, you must pass a string text as a parameter value
string FindLinksInText
Exceptions : Invalid URI ,is not a Youtube URL

Example:

YouTubeTv.DetectURL detectURL = new YouTubeTv.DetectURL();
if (detectURL.IsValidURL(detectURL.DetectURLLInk(this.VideoLinktxt.Text)) == true)
{
//Code to excute
}

dectecturlclass

YouTube Class Members

VideoUrl

Returns the Youtube video URL ready to play.

VideoId

Returns the Id of the Youtube video.

VideoImageUrl

Returns the Youtube video image URL.

ProvidedUrl

Returns the Youtube video URL provided.

Width

Returns the Width of the video Frame ,the default is '560px'

Height

Returns the Height of the video Frame ,the default is '315px'

Example:

YouTubeTv.DetectURL detectURL = new YouTubeTv.DetectURL();
if (detectURL.IsValidURL(detectURL.DetectURLLInk(this.VideoLinktxt.Text)) == true)
{
YouTubeTv.YouTube TV = new YouTubeTv.YouTube(this.VideoLinktxt.Text);
}
else
{

//message to the user
Response.Write("Error");
}

Youtubetvclass

Here is a complete sample code you can use this sample is added with the downloaded project.
videolinkfromtext.cs code

YoutubetvclassCodesample

The HTML code
videolinkfromtext.aspx code

YoutubetvclassCodesamplehtml

PLayList Class

The playList class allows you to create a list of video you want , for example, You want to create a 10 videos and load to the web page, it makes easy just adding the Youtube video Url and it will be populated the image of the video and it will handle the click event of each button , and it will be ready to play, it is already created for you!, another feature added is that you can add description that you want and it will be added at the bottom of each video, but you can style it as you want by adding a CSS class.
PlayList class require that you create a collection of CreatePlayList PlayList exposes the following member

Load()

The Load Function require the following parameters

playlistContainer

This container must be an ASP Panel where the Video Images will be added

screentv

This container must be HtmlFrame web control with the attribute runat='server' this control will show the video when the user clicks the video image

PlayList

This is a collection required with List< CreatePlayList > PlayList

CreatePlayList Class Members

Description

Description of the video 'normal it appear at the bottom of the image but you can style it with 'DescriptionCSS' property

DescriptionCSS

'CSS Class' style the description object example: All CSS styles like 'color,font-size etc. you must create a CSS Class'

ImageCSS

'CSS Class' style the Image object example: All CSS styles like 'color,font-size etc. you must create a CSS Class'

VideoUrl

Set or get the video url of the play list

Example:

YoutubetvPlayList

After you have been filled all properties shown in the image you will need create an instance of PlayList Class

YoutubetvPlayListCreate

Here is a complete sample code you can use, this sample is added with the downloaded project.
playlist.cs code

YoutubetvPlayListCode

The HTML code
playlist.aspx code

YoutubetvPlayListCodeHtml

YouTubeTv For Windows Application

For windows Application you will need Add reference to "Shockwave Flash Object"
If you don't know how to add reference to this Component please Refer to this tutorial Flash Player Object en C# after you have added reference to "Shockwave Flash Object" you will find easy to work with it. The samples contains all code developed Ready to use.

The following image is from the Windows application, there are some different controls that is used to web application , but we have the power of the Library that does all we need.
The controls that are on this Windows form are:

  • Shockwave Flash Object
  • flowLayoutPanel
  • PictureBox

The picturebox are the video images you see on the Windows Form that are created at Run-Time and added to the flowLayoutPanel.

ForWindows

C# Code sample

ForWindowsCSharpCode

VB.Net Code sample

ForWindowsVBCode





Arrowat MSDN Bing Github Twitter Facebook Linkedin

© 2024 Melvin Dev™