Get You Tube URL - CSharp Network

CSharp examples for Network:URL

Description

Get You Tube URL

Demo Code


using System.Web;
using System.Text.RegularExpressions;
using System.IO;/*from   w w w  . j a  va  2 s.com*/
using System.Security.Cryptography;
using System.Diagnostics;
using System.Collections.Generic;
using System;

public class Main{
        public static void GetYouTubeURL(string url, out string imageURL, out string videoURL)
        {

            int startIndex = Convert.ToInt32(url.LastIndexOf("="));
            int endIndex = url.Trim().Length;

            string baseImageUrl = "http://img.youtube.com/vi/";
            string imageName = url.Trim().Substring(startIndex + 1, endIndex - 1 - startIndex);
            //Image1.Width = 100;
            //Image1.Height = 100;
            //string imageUrl =  TextBox1.Text.ToString().Substring(Convert.ToInt32(TextBox1.Text.ToString().LastIndexOf("=")), TextBox1.Text.ToString().Length).ToString();
            //Image1.ImageUrl = baseImageUrl + imageName + "/default.jpg";
            ////HyperLink1.NavigateUrl = HttpContext.Current.Request.Url;
            //HyperLink1.ImageUrl = baseImageUrl + imageName + "/default.jpg";
            //HyperLink1.NavigateUrl = HttpContext.Current.Request.Url.ToString();

            imageURL = baseImageUrl + imageName + "/default.jpg";

            string baseVideoUrl = "http://www.youtube.com/v/";
            baseVideoUrl += imageName;
            videoURL = baseVideoUrl;
            //videoURL = string.Format("<embed runat='server' id='VideoPlayer' "
            //+ "src='{0}' type='application/x-shockwave-flash'"
            //+ "allowscriptaccess='always' allowfullscreen='true' width='425' height='344'> </embed>", baseVideoUrl);




            //string ss = string.Format("<object width='560' height='340'><param name='movie'"
            //                           + "value='http://www.youtube.com/v/A5xRqVZgE-c&hl=en&fs=1&'>"
            //                           + "</param><param name='allowFullScreen' value='true'></param>"
            //                           + "<param name='allowscriptaccess' value='always'></param>"
            //                           + "<embed src='http://www.youtube.com/v/A5xRqVZgE-c&hl=en&fs=1&' "
            //                           + "type='application/x-shockwave-flash' allowscriptaccess='always' "
            //                           + "allowfullscreen='true' width='560' height='340'></embed></object>");

            //http://www.youtube.com/v/SQDlsbn349Y

            //string baseVideoUrl = "http://www.youtube.com/v/";
            //baseVideoUrl += imageName + "?autoplay=1";
            //string ss = string.Format("<embed runat='server' id='VideoPlayer' "
            //            + "src='{0}' type='application/x-shockwave-flash'"
            //            + "allowscriptaccess='always' allowfullscreen='true' width='425' height='344'> </embed>", baseVideoUrl);

            //divId.InnerHtml = ss;
        }
}

Related Tutorials