this my presentation view
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="True" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server" method="post">
<asp:Label ID="l1" Text="" runat="server"></asp:Label>
<div>
<asp:Label ID="lbltitle" runat="server" Text="Title"></asp:Label><br />
<asp:TextBox ID="txttitle" runat="server"></asp:TextBox><br/>
<asp:Label ID="lbldescription" runat="server" Text="Description"></asp:Label><br/>
<asp:TextBox ID="txtDescription" Rows="5" TextMode="MultiLine" Columns="5" runat="server"
Height="46px" Width="125px"></asp:TextBox><br/>
<asp:Label ID="lblCatogery" runat="server" Text="Catogery"></asp:Label><br/>
<asp:DropDownList ID="ddlcatogery" runat="server" Height="16px" Width="123px">
<asp:ListItem Value="Autos">Autos & Vehicles</asp:ListItem>
<asp:ListItem Value="Music">Music</asp:ListItem>
<asp:ListItem Value="Animals">Pets & Animals</asp:ListItem>
<asp:ListItem Value="Sports">Sports</asp:ListItem>
<asp:ListItem Value="Travel">Travel & Events</asp:ListItem>
<asp:ListItem Value="Games">Gadgets & Games</asp:ListItem>
<asp:ListItem Value="Comedy">Comedy</asp:ListItem>
<asp:ListItem Value="People">People & Blogs</asp:ListItem>
<asp:ListItem Value="News">News & Politics</asp:ListItem>
<asp:ListItem Value="Entertainment">Entertainment</asp:ListItem>
<asp:ListItem Value="Education">Education</asp:ListItem>
<asp:ListItem Value="Howto">Howto & Style</asp:ListItem>
<asp:ListItem Value="Nonprofit">Nonprofit & Activism</asp:ListItem>
<asp:ListItem Value="Tech">Science & Technology</asp:ListItem>
</asp:DropDownList><br />
<asp:Label ID="lblkeywords" runat="server" Text="Key words"></asp:Label><br/>
<asp:TextBox ID="txtkeywords" runat="server"></asp:TextBox><br/><br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br /><br />
<asp:Button ID="Button1" runat="server" Text="Upload on youtube" onclick="Button1_Click" /> <br />
</div>
</form>
<div>
</div>
</body>
</html>
Default.aspx.cs
using System;
using System.Configuration;
using Google.YouTube;
using Google.GData.YouTube;
using Google.GData.Client;
using Google.GData.Extensions.MediaRss;
using System.Threading;
public partial class _Default : System.Web.UI.Page
{
private static readonly string YouTubeDeveloperKey = ConfigurationManager.AppSettings["YouTubeDeveloperKey"];
private static readonly string YouTubeCompany = ConfigurationManager.AppSettings["YouTubeCompany"];
private static readonly string YoutubeUserName = ConfigurationManager.AppSettings["YoutubeUserName"];
private static readonly string YoutubePassword = ConfigurationManager.AppSettings["YoutubePassword"];
string youtubeurl;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["title"] = txttitle.Text;
Session["description"] = txtDescription.Text;
string FileName = FileUpload1.FileName;
string fillPath = FileUpload1.PostedFile.FileName;
string content = FileUpload1.PostedFile.ContentType;
var newp = Server.MapPath("download/" + FileName);
FileUpload1.SaveAs(Server.MapPath("download/" + FileName));
try
{
var settings = new YouTubeRequestSettings("Ramdeo", YouTubeDeveloperKey, YoutubeUserName, YoutubePassword)
{
Timeout = int.MaxValue
};
YouTubeRequest request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = txttitle.Text.Trim();
newVideo.Tags.Add(new MediaCategory(ddlcatogery.SelectedItem.Text, YouTubeNameTable.CategorySchema));
newVideo.Description = txtDescription.Text.Trim();
newVideo.Keywords = txtkeywords.Text.Trim();
newVideo.YouTubeEntry.Private = false;
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(newp, content);
Video A = request.Upload(newVideo);
System.IO.File.Delete(Request.PhysicalApplicationPath + "download/" + FileName);
Session["youtubeurl"] = "http://www.youtube.com/v/" + A.VideoId + "&hl=en_US&fs=1&rel=0";
Response.Redirect("viewVideo.aspx");
//Response.Redirect("viewVideo.aspx?Name=" + txttitle.Text+"descr="+txtDescription.Text+"url="+l1.Text);
}
catch(Exception ex)
{
}
}
}
Sometime this code works sometimes not.please help me i am tired now.i have been working on this problem since 10 days.
please...............help me...
if it is possible then give the code to upload video using API 3.0 in ASP.NET