Click here to Skip to main content
14,981,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I create a Creating a Media Player which supports all Browsers?
This is my coding for DLL:

C#
[Bindable(true), Category("Settings"), Description("Would movie play when page is loaded.")]
      public 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"), Description("Balance")]
      int Balance
      {
            get
            {
                  if (ViewState["Balance"] == null)
                        return DefaultBalance;
                  else
                        return (int)ViewState["Balance"];
            }
            set
            {
                  if(value > 100)
                        value = 100;
                  if(value < -100)
                        value = -100;
                  if(value != DefaultBalance)
                        ViewState["Balance"] = value;
                  else
                        ViewState["Balance"] = null;
            }
      }
 
      [Bindable(true), Category("Settings"), Description("Current postion.")]
      int CurrentPosition
      {
            get
            {
                  if(ViewState["CurrentPosition"] == null)
                        return DefaultCurrentPosition;
                  else
                        return (int)ViewState["CurrentPosition"];
            }
            set
            {
                  if(value < 0)
                        value = 0;
                  if(value != DefaultCurrentPosition)
                        ViewState["CurrentPosition"] = value;
                  else
                        ViewState["CurrentPosition"] = null;
            }
      }
 
      [Bindable(true), Category("Settings")]
      bool EnableContextMenu
      {
            get
            {
                  if(ViewState["EnableContextMenu"] == null)
                        return DefaultEnableContextMenu;
                  else
                        return (bool)ViewState["EnableContextMenu"];
            }
            set
            {
                  if(value != DefaultEnableContextMenu)
                        ViewState["EnablecontextMenu"] = value;
                  else
                        ViewState["EnablecontextMenu"] = null;
            }
      }
 
      [Bindable(true), Category("Settings"), Description("Would movie be played in full screen.")]
      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"), Description("Play video without sound.")]
      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"), Description("How much times will video play.")]
      int PlayCount
      {
            get
            {
                  if(ViewState["PlayCount"] == null)
                        return DefaultPlayCount;
                  else
                        return (int)ViewState["PlayCount"];
            }
            set
            {
                  if(value < 1)
                        value = 1;
                  if(value != DefaultPlayCount)
                        ViewState["PlayCount"] = value;
                  else
                        ViewState["PlayCount"] = null;
            }
      }
 
      [Bindable(true), Category("Settings")]
      System.Single Rate
      {
            get
            {
                  if(ViewState["Rate"] == null)
                        return DefaultRate;
                  else
                        return (float)ViewState["Rate"];
            }
            set
            {
                  if(value < 0.0)
                        value = (float)1.0;
                  if(value != DefaultRate)
                        ViewState["Rate"] = value;
                  else
                        ViewState["Rate"] = null;
            }
      }
      
      [Bindable(true), Category("Settings")]
      bool StretchToFit
      {
            get
            {
                  if(ViewState["StretchToFit"] == null)
                        return DefaultStretchToFit;
                  else
                        return (bool)ViewState["StretchToFit"];
            }
            set
            {
                  if(value != DefaultStretchToFit)
                        ViewState["StretchToFit"] = value;
                  else
                        ViewState["StretchToFit"] = null;
            }
      }
 
      [Bindable(true), Category("Settings"), Description("Set how player will look like.")]
      Enumerations.PlayerMode uiMode
      {
            get
            {
                  if(ViewState["uiMode"] == null)
                        return DefaultUIMode;
                  else
                        return (Enumerations.PlayerMode)ViewState["uiMode"];
            }
            set
            {
                  if(value != DefaultUIMode)
                        ViewState["uiMode"] = value;
                  else
                        ViewState["uiMode"] = null;
            }
      }
 
      [Bindable(true), Category("Settings"), Description("Set sound volume")]
      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;
            }
      }
      #endregion
 
      #region Private functions
      private string getPlayerMode() 
      {
            switch(uiMode)
            {
                  case Enumerations.PlayerMode.Invisible:
                        return "invisible";
                  case Enumerations.PlayerMode.Mini:
                        return "mini";
                  case Enumerations.PlayerMode.None:
                        return "none";
                  default:
                        return "full";
            }
      }
      #endregion
 
      #region Render
      [Description("Render control, depending of property values")]
      protected override void RenderContents(HtmlTextWriter output)
      {
            StringBuilder content = new StringBuilder();
            content.Append("<OBJECT width=\"" + Width.ToString() + "\" height=\"" + Height.ToString() +
                  "\" CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" VIEWASTEXT>\n");
            content.Append("<param name="\"autoStart\"" value="\""" autostart="">\n");
            content.Append("<param name="\"URL\"" value="\""" movieurl="">\n");
            content.Append("<param name="\"enabled\"" value="\""" enabled="">\n");
            content.Append("<param name="\"balance\"" value="\""" balance="">\n");
            content.Append("<param name="\"currentPosition\"" value="\""" currentposition="">\n");
            content.Append("<param name="\"enableContextMenu\"" value="\""" enablecontextmenu="">\n");
            content.Append("<param name="\"fullScreen\"" value="\""" fullscreen="">\n");
            content.Append("<param name="\"mute\"" value="\""" mute="">\n");
            content.Append("<param name="\"playCount\"" value="\""" playcount="">");
            content.Append("<param name="\"rate\"" value="\""" rate="">");
            content.Append("<param name="\"stretchToFit\"" value="\""" stretchtofit="">");
            content.Append("<param name="\"uiMode\"" value="\""">");
            if(Volume >= 0)
                  content.Append("<param name="\"volume\"" value="\""" volume="">");
            content.Append("</OBJECT>");
            output.Write(content.ToString());
      }
}
#endregion
 
#region Enumerations
namespace Enumerations
{
      [Description("Player mode can be Invisible, None, Mini and Full")]
      public enum PlayerMode
      {
            Invisible = 0,
            None = 1,
            Mini = 2,
            Full = 3
      }
}
#endregion
Posted
Updated 25-Feb-15 22:35pm
v4
Comments
Afzaal Ahmad Zeeshan 26-Feb-15 4:08am
   
How would you bind it to browser then?
Member 11314356 26-Feb-15 4:30am
   
these coding showing a error in these lines
Richard MacCutchan 26-Feb-15 6:04am
   
What errors, where are they? Please do not expect people to guess what is wrong with your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900