开发者

Change the contents of youtube embended link

开发者 https://www.devze.com 2023-01-06 08:53 出处:网络
This is a very simple complexive query that I have. I need the solution. I have a youtube link <----- width=\"480\" height=\"350\"><param name=\"movie\"

This is a very simple complexive query that I have. I need the solution. I have a youtube link

 <----- width="480" height="350"><param name="movie"
 value="http://www.youtube.com/v/OORDOd6wRrE&amp;hl=en_US&amp;fs=1"></param><param
 name="allowFullScreen" value="true"></param><param
 name="allowscriptaccess" value="always"></param><----
 src="http://www.youtube.com/v/OORDOd6wRrE&amp;hl=en_US&amp;fs=1"
 type="application/x-shockwave-flash" allowscriptaccess="always"
 allowful开发者_JAVA百科lscreen="true" width="480" height="350"><---><----->

this is the modified link. Well, my problem is, that I want to change the size of video, means in the whole string I want to replace width="480" with width="250" and height="350" with height="250"

I want to change these parameters programmatically using ASP.Net

Thanks


So what seems to be the problem?

This worked for me:

<object height="250" width="250">
    <param name="movie" value="http://www.youtube.com/v/OORDOd6wRrE"> 
    <param name="allowfullscreen" value="true"> 
    <param name="wmode" value="opaque"> 
    <embed src="http://www.youtube.com/v/OORDOd6wRrE" type="application/x-shockwave-flash" allowfullscreen="true" wmode="opaque" height="250" width="250"> 
</object>

However you should change the height and width according to the H/W ratio in order for the movie not to become distorted.

EDIT:

After seeing OPs answer I think I understand what he's trying to do. For this my suggestion is to use regular expressions like so:

temp = Regex.Replace(strInput, "width=\"\d*\"", "width=\"250\"");
result = Regex.Replace(temp, "height=\"\d*\"", "height=\"250\"");

Also, check out the following tutorial: Regular Expressions in ASP.NET.


I got my solution.

Define one user define function
private bool IsInt(string IntValue)
{
      try
      {
            int iValue = int.Parse(IntValue);
      }
      catch (Exception Ex) { return false;}

     return true;
}

    string str=txt_Links.Text;
    string lastNo = "";
    bool firstNoFound = false;
    for (int strIdx = 0; strIdx <= str.Length - 1; strIdx++)
    {
        if (IsInt(str.Substring(strIdx, 1)) == true)
        {
            lastNo = lastNo + str.Substring(strIdx, 1);
            firstNoFound = true;
        }
        else
        {
            if (firstNoFound == true)
            {
                //Page.Title = lastNo;
                str = str.Replace("width=\"" + lastNo + "\"", "width=\"250\"").Replace("height=\"" + lastNo + "\"", "height=\"250\"");
                lastNo = "";
                firstNoFound = false;
            }
        }
    }

    Response.Write(str);
0

精彩评论

暂无评论...
验证码 换一张
取 消