posts - 211,  comments - 1174,  trackbacks - 43

  在编辑文章的时候添加Flash总是把embed等内容过虑了,看了一下帮助原来可以写一个Extension来处理。

/// <summary>

/// sample:[flash:http://smark.nbao.net/ShowEffectSample.swf 600 400]

/// </summary>

[Extension("FlashPlayer", "1.0.0.0", "smark.nbao.net")]

public class FlashPlayer

{

 

 

    public FlashPlayer()

    {

        Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving);

    }

 

 

    private void Post_Serving(object sender, ServingEventArgs e)

    {

        if (!string.IsNullOrEmpty(e.Body))

        {

         

            if (e.Location == ServingLocation.PostList || e.Location == ServingLocation.SinglePost)

            {

                string regex = @"\[flash:(http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*))(\s+)(\d*)(\s+)(\d*)\]";

                MatchCollection matches = Regex.Matches(e.Body, regex);

 

                if (matches.Count > 0)

                {

                  

 

                    string filename, width, height;

 

                    Match match = Regex.Match(e.Body, regex);

                    if (match.Length > 0)

                    {

                        filename = match.Groups[1].Value;

                        width = match.Groups[match.Groups.Count - 3].Value;

                        height = match.Groups[match.Groups.Count - 1].Value;

 

 

                        string player = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""

                                + "id=\"ShowEffectSample\" width=\"{1}\" height=\"{2}\""

                                + "codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab\">"

                                + "<param name=\"movie\" value=\"{0}\" />"

                                + "<param name=\"quality\" value=\"high\" />"

                                + "<param name=\"bgcolor\" value=\"#869ca7\" />"

                                + "<param name=\"allowScriptAccess\" value=\"sameDomain\" />"

                                + "<embed src=\"{0}\" quality=\"high\""

                                + "width=\"{1}\" height=\"{2}\"  align=\"middle\""

                                + "play=\"true\""

                                + "loop=\"false\""

                                + "quality=\"high\""

                                + "allowScriptAccess=\"sameDomain\""

                                + "type=\"application/x-shockwave-flash\""

                                + "pluginspage=\"http://www.adobe.com/go/getflashplayer\">"

                                + "</embed>"

                            + "</object>";

                        e.Body = e.Body.Replace(match.Value, string.Format(player, filename, width, height));

                    }

 

                }

            }

        }

    }

 http://smark.nbao.net

0
0
(请您对文章做出评价)
« 上一篇:搬家
» 下一篇:Asp.net + Flex实现网络硬盘
posted on 2009-05-05 12:04 henry 阅读(407) 评论(2)  编辑 收藏

FeedBack:
2009-05-06 10:00 | Jeason      
呵呵,楼主,哪个版本的DotNetBlogEngine?
  回复  引用  查看    
#2楼[楼主]
2009-05-06 11:41 | henry      
@Jeason
BlogEngine.NET 1.5.0.7

  回复  引用  查看    
<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

搜索

 
 

常用链接

我的标签

随笔分类

最新评论