MediaPlayer WebControl problem

Discussion in 'ASP .Net Web Controls' started by Jeronimo Bertran, Jun 4, 2006.

  1. Hello,

    I am creating a Web control then encapsulates a MediaPlayer.



    [ToolboxData("<{0}:MediaPlayer runat=server></{0}:MediaPlayer>")]
    public class MediaPlayer : WebControl
    {
    [Bindable(true)]
    [Category("Appearance")]
    [DefaultValue("")]
    public string Url
    {
    get
    {
    String s = (String)ViewState["Url"];
    return ((s == null) ? String.Empty : s);
    }

    set
    {
    ViewState["Url"] = value;
    }
    }

    protected override void RenderContents(HtmlTextWriter writer)
    {
    HtmlGenericControl player = new HtmlGenericControl
    ("object");
    player.ID = this.ClientID + "_player";
    player.Attributes["classid"] ="CLSID:6BF52A52-394A-11d3-
    B153-00C04F79FAA6";

    player.InnerHtml = "<PARAM name=\"URL\" value=\"" + (String)
    ViewState["Url"] + "\"> <PARAM name=\"autoStart\" value=\"false\">";
    player.RenderControl(writer);


    writer.Write(this.ClientID);
    }



    The control produces the following HTML.


    <span id="MediaPlayer1">
    <object id="MediaPlayer1_player" classid="CLSID:6BF52A52-394A-11d3-B153-
    00C04F79FAA6"><PARAM name="URL" value="Beep.wav"> <PARAM
    name="autoStart" value="false"></object>MediaPlayer1</span>


    I am trying to access the object from the page :

    input id="Button1" type="button" value="button" onclick="MediaPlayer1
    _palyer.controls.play()" />


    But I get the following error:

    Error:'MediaPlayer1_player' is undefined


    How can I access the object from outside the span??

    Thanks

    Jeronimo Bertran
    Jeronimo Bertran, Jun 4, 2006
    #1
    1. Advertising

  2. Hi Jeronimo,

    Thank you for your post.

    I was unable to repro the problem you described. The JavaScript
    "MediaPlayer1_player.controls.play()" works ok in my test project.

    Is the MediaPlayer rendered correctly in your browser?

    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Jun 5, 2006
    #2
    1. Advertising

  3. I also created a web control that encapsulates the media player.
    It is located here, along with sample code for calling methods client side
    as you are trying to do.
    It's all free:
    http://SteveOrr.net/articles/StreamingMedia.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Jeronimo Bertran" <> wrote in message
    news:Xns97D7DB15A6CEDpublicjbbertrancom@207.46.248.16...
    >
    > Hello,
    >
    > I am creating a Web control then encapsulates a MediaPlayer.
    >
    >
    >
    > [ToolboxData("<{0}:MediaPlayer runat=server></{0}:MediaPlayer>")]
    > public class MediaPlayer : WebControl
    > {
    > [Bindable(true)]
    > [Category("Appearance")]
    > [DefaultValue("")]
    > public string Url
    > {
    > get
    > {
    > String s = (String)ViewState["Url"];
    > return ((s == null) ? String.Empty : s);
    > }
    >
    > set
    > {
    > ViewState["Url"] = value;
    > }
    > }
    >
    > protected override void RenderContents(HtmlTextWriter writer)
    > {
    > HtmlGenericControl player = new HtmlGenericControl
    > ("object");
    > player.ID = this.ClientID + "_player";
    > player.Attributes["classid"] ="CLSID:6BF52A52-394A-11d3-
    > B153-00C04F79FAA6";
    >
    > player.InnerHtml = "<PARAM name=\"URL\" value=\"" + (String)
    > ViewState["Url"] + "\"> <PARAM name=\"autoStart\" value=\"false\">";
    > player.RenderControl(writer);
    >
    >
    > writer.Write(this.ClientID);
    > }
    >
    >
    >
    > The control produces the following HTML.
    >
    >
    > <span id="MediaPlayer1">
    > <object id="MediaPlayer1_player" classid="CLSID:6BF52A52-394A-11d3-B153-
    > 00C04F79FAA6"><PARAM name="URL" value="Beep.wav"> <PARAM
    > name="autoStart" value="false"></object>MediaPlayer1</span>
    >
    >
    > I am trying to access the object from the page :
    >
    > input id="Button1" type="button" value="button" onclick="MediaPlayer1
    > _palyer.controls.play()" />
    >
    >
    > But I get the following error:
    >
    > Error:'MediaPlayer1_player' is undefined
    >
    >
    > How can I access the object from outside the span??
    >
    > Thanks
    >
    > Jeronimo Bertran
    Steve C. Orr [MVP, MCSD], Jun 9, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Loupatty

    Controlling startposition mediaplayer

    Richard Loupatty, Apr 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    382
    Steve C. Orr [MVP, MCSD]
    Apr 6, 2005
  2. rosmi
    Replies:
    0
    Views:
    316
    rosmi
    Nov 24, 2003
  3. rosmi
    Replies:
    0
    Views:
    353
    rosmi
    Nov 24, 2003
  4. Klaus Andersen

    parameters for mediaplayer and html

    Klaus Andersen, Sep 5, 2004, in forum: HTML
    Replies:
    5
    Views:
    17,715
    Spartanicus
    Sep 6, 2004
  5. MrC

    Microsoft MediaPlayer

    MrC, Sep 11, 2004, in forum: HTML
    Replies:
    5
    Views:
    406
Loading...

Share This Page