JW FLV Player ASP.NET Control - C# Source Code
This is C# source code for custom ASP.NET JW FLV Flash Video Player Control. More about this control you can read at How to build ASP.NET FLV Flash Video Player Control. VB.NET source code is also available here.
using
System;
using
System.ComponentModel;
using
System.Text;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
[ToolboxData("<{0}:FlashPlayer runat=server></{0}:FlashPlayer>")]
public
class FlashPlayer : WebControl
{
#region Properties defaults
const string
DefaultSwfobject_jsLocation = ""; // in the same
directory
const string
DefaultFlashPlayerLocation = ""; // in the same
directory
const bool
DefaultAllowFullScreen = true;
const string
DefaultFile = "";
const bool
DefaultAutoStart = false;
const int
DefaultBufferLength = 1;
const bool
DefaultFullScreen = false;
const bool
DefaultMute = false;
const bool
DefaultQuality = true;
const int
DefaultVolume = 90;
#endregion
[Bindable(true), Category("Settings")]
string Swfobject_jsLocation
{
get
{
if(ViewState["Swfobject_jsLocation"]
== null)
return
DefaultSwfobject_jsLocation;
else
return (string)ViewState["Swfobject_jsLocation"];
}
set
{
if(value
!= DefaultSwfobject_jsLocation)
ViewState["Swfobject_jsLocation"] =
value;
else
ViewState["Swfobject_jsLocation"] =
null;
}
}
[Bindable(true), Category("Settings")]
string FlashPlayerLocation
{
get
{
if(ViewState["FlashPlayerLocation"]
== null)
return
DefaultFlashPlayerLocation;
else
return (string)ViewState["FlashPlayerLocation"];
}
set
{
if(value
!= DefaultFlashPlayerLocation)
ViewState["FlashPlayerLocation"] =
value;
else
ViewState["FlashPlayerLocation"] =
null;
}
}
[Bindable(true), Category("Settings")]
bool AllowFullScreen
{
get
{
if(ViewState["AllowFullScreen"]
== null)
return
DefaultAllowFullScreen;
else
return (bool)ViewState["AllowFullScreen"];
}
set
{
if(value
!= DefaultAllowFullScreen)
ViewState["AllowFullScreen"] =
value;
else
ViewState["AllowFullScreen"] =
null;
}
}
[Bindable(true), Category("Settings")]
string File
{
get
{
if(ViewState["File"] ==
null)
return DefaultFile;
else
return (string)ViewState["File"];
}
set
{
if(value
!= DefaultFile)
ViewState["File"] = value;
else
ViewState["File"] = null;
}
}
[Bindable(true), Category("Settings")]
bool AutoStart
{
get
{
if(ViewState["AutoStart"] ==
null)
return DefaultAutoStart;
else
return (bool)ViewState["AutoStart"];
}
set
{
if(value
!= DefaultAutoStart)
ViewState["AutoStart"] = value;
else
ViewState["AutoStart"] = null;
}
}
[Bindable(true), Category("Settings")]
int BufferLength
{
get
{
if(ViewState["BufferLength"]
== null)
return
DefaultBufferLength;
else
return (int)ViewState["BufferLength"];
}
set
{
if(value
!= DefaultBufferLength)
ViewState["BufferLength"] =
value;
else
ViewState["BufferLength"] =
null;
}
}
[Bindable(true), Category("Settings")]
bool FullScreen
{
get
{
if(ViewState["FullScreen"] ==
null)
return
DefaultFullScreen;
else
return (bool)ViewState["FullScreen"];
}
set
{
if(value
!= DefaultFullScreen)
ViewState["FullScreen"] = value;
else
ViewState["FullScreen"] = null;
}
}
[Bindable(true), Category("Settings")]
bool Mute
{
get
{
if(ViewState["Mute"] ==
null)
return DefaultMute;
else
return (bool)ViewState["Mute"];
}
set
{
if(value
!= DefaultMute)
ViewState["Mute"] = value;
else
ViewState["Mute"] = null;
}
}
[Bindable(true), Category("Settings")]
bool Quality
{
get
{
if(ViewState["Quality"] ==
null)
return DefaultQuality;
else
return (bool)ViewState["Quality"];
}
set
{
if(value
!= DefaultQuality)
ViewState["Quality"] = value;
else
ViewState["Quality"] = null;
}
}
[Bindable(true), Category("Settings")]
int Volume
{
get
{
if(ViewState["Volume"] ==
null)
return DefaultVolume;
else
return (int)ViewState["Volume"];
}
set
{
if(value
!= DefaultVolume)
ViewState["Volume"] = value;
else
ViewState["Volume"] = null;
}
}
protected override
void RenderContents(HtmlTextWriter output)
{
StringBuilder content = new StringBuilder();
content.Append("<div id=\"" + ClientID +
"container\"><a
href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to
see this player.</div>\n");
content.Append("<script type=\"text/javascript\" src=\"" + Swfobject_jsLocation
+ "swfobject.js\"></script>\n");
content.Append("<script type=\"text/javascript\">\n");
content.Append("var s1 = new SWFObject(\"" + FlashPlayerLocation +
"player.swf\",\"ply\",\"" + Width.ToString() + "\",\"" +
Height.ToString() + "\",\"#FFFFFF\")\n");
content.Append("s1.addParam(\"allowfullscreen\",\"" +
AllowFullScreen.ToString().ToLower() +
"\")\n");
content.Append("s1.addVariable(\"file\",\"" + File + "\"\n)");
content.Append("s1.addVariable(\"autostart\", \"" +
AutoStart.ToString().ToLower() + "\")\n");
content.Append("s1.addVariable(\"bufferlength\", \"" + BufferLength.ToString() +
"\")\n");
content.Append("s1.addVariable(\"fullscreen\", \"" +
FullScreen.ToString().ToLower() + "\")\n");
content.Append("s1.addVariable(\"mute\", \"" + Mute.ToString().ToLower() +
"\")\n");
content.Append("s1.addVariable(\"quality\", \"" + Quality.ToString().ToLower() +
"\")\n");
content.Append("s1.addVariable(\"volume\", \"" + Volume.ToString() + "\")\n");
content.Append("s1.write(\"" + ClientID + "container\")\n");
content.Append("</script>");
output.Write(content);
}
}
|