Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > MediaPlayer WebControl problem

Reply
Thread Tools

MediaPlayer WebControl problem

 
 
Jeronimo Bertran
Guest
Posts: n/a
 
      06-04-2006

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
 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      06-05-2006
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.

 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      06-09-2006
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom webcontrol that references another webcontrol Fabricio ASP .Net Building Controls 0 09-21-2005 02:55 AM
Trapping an Exception ocurring in a Webcontrol at the Page or parent WebControl level. ASP .Net 2 01-31-2005 06:34 PM
WebControl inside of WebControl and attaching events Kasabaarde Sumta ASP .Net Building Controls 0 12-13-2004 09:51 PM
WebControl with non-WebControl property Peter Morris [Air Software Ltd] ASP .Net Web Controls 1 12-07-2004 12:25 PM
Can a webcontrol (webcontrol.dll) have a configuration file? Luis Ramírez. ASP .Net Building Controls 2 07-06-2004 04:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57