using System; using System.Drawing; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; [assembly: TagPrefix("Player", "MM")] namespace Macromedia.Flash { [ToolboxData("<{0}:Player runat=\"server\"></{0}:Player>")] public class Player : WebControl { private string mediaurl,alternateimageurl,alternatelinkurl,alternatelinktarget,alternatelinkonclick,quality,menu,scale,salign,wmode,bgcolor,flashvars; private string alternateimagetext = ""; private Unit width,height; private int requiredversion=1; public override Unit Width { get { return width; } set { width = value; } } public override Unit Height { get { return height; } set { height = value; } } public int RequiredVersion { get { return requiredversion; } set { requiredversion = value; } } public string AlternateImageUrl { get { return alternateimageurl; } set { alternateimageurl = value; } } public string AlternateLinkUrl { get { return alternatelinkurl; } set { alternatelinkurl = value; } } public string AlternateLinkTarget { get { return alternatelinktarget; } set { alternatelinktarget = value; } } public string AlternateLinkOnclick { get { return alternatelinkonclick; } set { alternatelinkonclick = value; } } public string AlternateImageText { get { return alternateimagetext; } set { alternateimagetext = value; } } public string Quality { get { return quality; } set { quality = value; } } public string Menu { get { return menu; } set { menu = value; } } public string Scale { get { return scale; } set { scale = value; } } public string SAlign { get { return salign; } set { salign = value; } } public string WMode { get { return wmode; } set { wmode = value; } } public string BgColor { get { return bgcolor; } set { bgcolor = value; } } public string MediaUrl { get { return mediaurl; } set { mediaurl = value; } } public string FlashVars { get { return flashvars; } set { flashvars = value; } } protected override void Render (HtmlTextWriter writer) { writer.WriteBeginTag("script"); writer.WriteAttribute("type","text/javascript"); writer.WriteLine(HtmlTextWriter.TagRightChar); writer.WriteLine("<!--"); writer.WriteLine("var agt = navigator.userAgent.toLowerCase();"); writer.WriteLine("var ie = (agt.indexOf(\"msie\") != -1);"); writer.WriteLine("var ns = (navigator.appName.indexOf(\"Netscape\") != -1) || (navigator.appName.indexOf(\"Opera\") !"= -1);"); writer.WriteLine("var win = ((agt.indexOf(\"win\")!=-1) || (agt.indexOf(\"32bit\")!=-1));"); writer.WriteLine("var mac = (agt.indexOf(\"mac\")!=-1);"); writer.WriteLine("var rqversion = " + requiredversion.ToString() + ";"); writer.WriteLine("var result = false;"); writer.WriteLine("if (ie && win)"); writer.WriteLine("{"); writer.WriteLine(" document.writeln('<script type=\"text/vbscript\">');"); writer.WriteLine(" document.writeln(' On Error Resume Next');"); writer.WriteLine(" document.writeln(' result = IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.'+rqversion+'\""))');"); writer.WriteLine(" document.writeln('</scr' + 'ipt>');"); writer.WriteLine("}"); writer.WriteLine("if (ns || !win)"); writer.WriteLine("{"); writer.WriteLine(" if (navigator.mimeTypes && navigator.mimeTypes[\"application/x-shockwave-flash\"] && navigator.mimeTypes[\&q""uot;application/x-shockwave-flash\"].enabledPlugin)"); writer.WriteLine(" {"); writer.WriteLine(" if (navigator.plugins && navigator.plugins[\"Shockwave Flash\"] && (versionIndex = navigator.plu"""""gins[\"Shockwave Flash\"].description.indexOf(\".\")) != - 1)"); writer.WriteLine(" {"); writer.WriteLine(" var versionString = navigator.plugins[\"Shockwave Flash\"].description.substring(ver"sionIndex-1,versionIndex);"); writer.WriteLine(" versionIndex = parseInt( versionString );"); writer.WriteLine(" if ( versionIndex >= rqversion )"); writer.WriteLine(" result = true;"); writer.WriteLine(" }"); writer.WriteLine(" }"); writer.WriteLine("}"); writer.WriteLine("if (result)"); writer.WriteLine("{"); writer.Write(" document.writeln('"); writer.WriteBeginTag("object"); if (ID != null) writer.WriteAttribute("id",ClientID); writer.WriteAttribute("classid","CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000"); writer.WriteAttribute("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"); writer.WriteAttribute("width",width.ToString()); writer.WriteAttribute("height",height.ToString()); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteLine("');"); if (mediaurl != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","filename"); writer.WriteAttribute("value",mediaurl); writer.WriteAttribute("valuetype","ref"); writer.WriteAttribute("type","video/*"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","movie"); writer.WriteAttribute("value",mediaurl); writer.WriteAttribute("valuetype","ref"); writer.WriteAttribute("type","video/*"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","src"); writer.WriteAttribute("value",mediaurl); writer.WriteAttribute("valuetype","ref"); writer.WriteAttribute("type","video/*"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (quality != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","quality"); writer.WriteAttribute("value",quality); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (menu != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","menu"); writer.WriteAttribute("value",menu); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (wmode != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","wmode"); writer.WriteAttribute("value",wmode); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (scale != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","scale"); writer.WriteAttribute("value",scale); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (salign != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","salign"); writer.WriteAttribute("value",salign); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (bgcolor != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","bgcolor"); writer.WriteAttribute("value",bgcolor); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } if (flashvars != null) { writer.Write(" document.writeln(' "); writer.WriteBeginTag("param"); writer.WriteAttribute("name","flashvars"); writer.WriteAttribute("value",flashvars); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine("');"); } writer.Write(" document.writeln(' "); writer.WriteBeginTag("embed"); if (ID != null) writer.WriteAttribute("id",ClientID+"_2"); writer.WriteAttribute("pluginspage","http://www.macromedia.com/go/getflashplayer"); writer.WriteAttribute("type","application/x-shockwave-flash"); writer.WriteAttribute("width",width.ToString()); writer.WriteAttribute("height",height.ToString()); if (mediaurl != null) writer.WriteAttribute("src",mediaurl); if (mediaurl != null) writer.WriteAttribute("movie",mediaurl); if (mediaurl != null) writer.WriteAttribute("filename",mediaurl); if (quality != null) writer.WriteAttribute("quality",quality); if (menu != null) writer.WriteAttribute("menu",menu); if (scale != null) writer.WriteAttribute("scale",scale); if (salign != null) writer.WriteAttribute("salign",salign); if (wmode != null) writer.WriteAttribute("wmode",wmode); if (bgcolor != null) writer.WriteAttribute("bgcolor",bgcolor); if (flashvars != null) writer.WriteAttribute("flashvars",flashvars); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteEndTag("embed"); writer.WriteLine("');"); writer.Write(" document.writeln('"); writer.WriteEndTag("object"); writer.WriteLine("');"); if (alternateimageurl != null) { writer.Write(" document.writeln('"); writer.WriteFullBeginTag("noembed"); writer.WriteLine("');"); writer.Write(" document.writeln(' "); writer.WriteBeginTag("a"); if (alternatelinkurl != null) writer.WriteAttribute("href",alternatelinkurl); else writer.WriteAttribute("href","#"); if (alternatelinkonclick != null) writer.WriteAttribute("onclick",alternatelinkonclick.Replace("'", "\\'")); if (alternatelinktarget != null) writer.WriteAttribute("target",alternatelinktarget); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteBeginTag("img"); writer.WriteAttribute("src",alternateimageurl); writer.WriteAttribute("width",width.ToString()); writer.WriteAttribute("height",height.ToString()); writer.WriteAttribute("border","0"); writer.WriteAttribute("alt",alternateimagetext); writer.WriteAttribute("galleryimg","no"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteEndTag("a"); writer.WriteLine("');"); writer.Write(" document.writeln('"); writer.WriteEndTag("noembed"); writer.WriteLine("');"); } writer.WriteLine("}"); if (alternateimageurl != null) { writer.WriteLine("else"); writer.WriteLine("{"); writer.Write(" document.writeln('"); writer.WriteBeginTag("a"); if (alternatelinkurl != null) writer.WriteAttribute("href",alternatelinkurl); else writer.WriteAttribute("href","#"); if (alternatelinkonclick != null) writer.WriteAttribute("onclick",alternatelinkonclick.Replace("'", "\\'")); if (alternatelinktarget != null) writer.WriteAttribute("target",alternatelinktarget); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteBeginTag("img"); writer.WriteAttribute("src",alternateimageurl); writer.WriteAttribute("width",width.ToString()); writer.WriteAttribute("height",height.ToString()); writer.WriteAttribute("border","0"); writer.WriteAttribute("alt",alternateimagetext); writer.WriteAttribute("galleryimg","no"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteEndTag("a"); writer.WriteLine("');"); writer.WriteLine("}"); } writer.WriteLine("// -->"); writer.WriteEndTag("script"); if (alternateimageurl != null) { writer.WriteLine(); writer.WriteFullBeginTag("noscript"); writer.WriteBeginTag("a"); if (alternatelinkurl != null) writer.WriteAttribute("href",alternatelinkurl); else writer.WriteAttribute("href","#"); if (alternatelinktarget != null) writer.WriteAttribute("target",alternatelinktarget); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteBeginTag("img"); writer.WriteAttribute("src",alternateimageurl); writer.WriteAttribute("width",width.ToString()); writer.WriteAttribute("height",height.ToString()); writer.WriteAttribute("border","0"); writer.WriteAttribute("alt",alternateimagetext); writer.WriteAttribute("galleryimg","no"); writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteEndTag("a"); writer.WriteEndTag("noscript"); } } } }