Video and Mediahttp://forums.silverlight.net//20.aspx/1?Video+and+MediaDiscussions about video and media in Silverlight applicationsMon, 01 Jan 0001 00:00:00 -05002073907http://forums.silverlight.net//p/21234/73907.aspx/1?Problems+loading+server+side+http+stream+in+MediaElementProblems loading server-side http stream in MediaElement <p>Hey,</p> <p>&nbsp;</p> <p>I have a problem playing a server-side stream in a MediaElement. I use the Silverlight 2 Beta 2 framework.</p> <p>&nbsp;</p> <p>My&nbsp;Silverlight code is as follows:</p> <font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>&lt;</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">UserControl</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> x</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">Class</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;MySilverlightSite.Controls.MusicPlayer&quot;</p> </font></font><font size="2"></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">xmlns</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</font></font><font size="2"> </font><font size="2"> <p></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">xmlns</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">x</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</font></font><font size="2"> </p> <p></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">Width</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;500&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> Height</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;30&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> xmlns</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">d</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</p> </font></font><font size="2"> <p></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">xmlns</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">mc</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> mc</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">Ignorable</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;d&quot;&gt;</p> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>&lt;</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">Grid</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</p> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>&lt;</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">MediaElement</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> IsMuted</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;False&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> x</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">:</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">Name</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;_MePlayMusic&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> Margin</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;0,0,0,0&quot;</font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2"> Source</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=&quot;http://MYIPADDRESS:PORTNUMBER/&quot; /&gt;</p> </font></font><font color="#a31515" size="2"><font color="#a31515" size="2"></font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&lt;/</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">Grid</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>&lt;/</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">UserControl</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</p> <p></font></font>&nbsp;</p> <p>I get the following error message when trying to run the code: 4001&nbsp;AG_E_NETWORK_ERROR. When I take the address to the stream (here in the code: <a href="http://MYIPADDRESS:PORTNUMBER/">http://MYIPADDRESS:PORTNUMBER/</a>)&nbsp;I would like to play and open it in Windows Media Player it opens perfectly so the address should be correct.</p> <p>&nbsp;</p> <p>I have tried to search this forum and google&nbsp;the error&nbsp;and couldn't find any solution to it. Hope any one&nbsp;on this forum&nbsp;have a solution&nbsp;to my problem.</p> <p>&nbsp;</p> <p>Thanks in advance.</p> 2008-07-23T14:02:36-04:0074539http://forums.silverlight.net//p/21234/74539.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p>Hello, have you encoded the file with Expression Encoder? Also make sure you're running your Silverlight application from the http protocol, not the local file system.</p> 2008-07-25T07:43:21-04:0074554http://forums.silverlight.net//p/21234/74554.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Yi-Lun Luo - MSFT</h4> <p>Hello, have you encoded the file with Expression Encoder? Also make sure you're running your Silverlight application from the http protocol, not the local file system.</p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Hey Yi-Lun,</p> <p>Thanks for your reply.</p> <p>It's not a file, but a live server-side&nbsp;http stream from a ShoutCast&nbsp;radio station so no I have not encoded it in Expression Encoder. I run the Silverlight application locally when developing it. Is that causing&nbsp;a problem?</p> 2008-07-25T08:39:45-04:0074561http://forums.silverlight.net//p/21234/74561.aspx/1?Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Problems loading server-side http stream in MediaElement <p>Make sure the stream returns VC-1 encoded contents (wmv). That's the only format supported by Silverlight.</p> 2008-07-25T09:06:38-04:0074565http://forums.silverlight.net//p/21234/74565.aspx/1?Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Yi-Lun Luo - MSFT</h4> <p>Make sure the stream returns VC-1 encoded contents (wmv). That's the only format supported by Silverlight.</p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>But it's not a video stream. It's an audio stream sent in Mp3-encoding. Why are you talking video?</p> 2008-07-25T09:29:18-04:0074568http://forums.silverlight.net//p/21234/74568.aspx/1?Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Problems loading server-side http stream in MediaElement <p>Not all mp3 is supported. Please refer to <a href="http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx"> http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx</a>.</p> 2008-07-25T09:43:58-04:0074572http://forums.silverlight.net//p/21234/74572.aspx/1?Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Yi-Lun Luo - MSFT</h4> <p>Not all mp3 is supported. Please refer to <a href="http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx"> http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx</a>.</p> <p></p> </blockquote> <p></p> <p>I have studied that page several times and the Mp3-stream should be supported.&nbsp;The stream is&nbsp;encoded as: MPEG Audio Layer-3 160Kbps Stereo. So that should not be a problem...</p> 2008-07-25T09:52:09-04:0075046http://forums.silverlight.net//p/21234/75046.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p>&nbsp;I've successfully loaded Shoutcast streams with SL2...</p> <p>You can <a href="http://www.flexiblefactory.co.uk/flexible/?p=53" target="_blank"> read about it here</a>... feel free to ask any questions in the comments <br> </p> <p>Things to remember:</p> <p>Replace http:// with mms:// for the url of the stream</p> <p>If the stream is the root of the server, follow it with a semi colon</p> <p>so, <b>http://shoutcastserver.net:8000/</b> would become <b>mms://shoutcastserver.net:8000/;</b></p> <p>Also, unless published online or on a local webserver, this will not work.<br> </p> 2008-07-27T23:32:09-04:0075239http://forums.silverlight.net//p/21234/75239.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>spender</h4> <p>&nbsp;I've successfully loaded Shoutcast streams with SL2...</p> <p>You can <a href="http://www.flexiblefactory.co.uk/flexible/?p=53" target="_blank"> read about it here</a>... feel free to ask any questions in the comments <br> </p> <p>Things to remember:</p> <p>Replace http:// with mms:// for the url of the stream</p> <p>If the stream is the root of the server, follow it with a semi colon</p> <p>so, <b>http://shoutcastserver.net:8000/</b> would become <b>mms://shoutcastserver.net:8000/;</b></p> <p>Also, unless published online or on a local webserver, this will not work.<br> </p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Thanks spender for your post. I've read 2 of your blogs with streaming and it was very interesting.</p> <p>I've tried the &quot;tricks&quot; you wrote and now I don't get any errors when playing the stream but I don't get any sound either [:(]</p> <p>What can I do about that?</p> <p>I run the&nbsp;xaml from my local machine. Will it work if I run it on a webserver?</p> 2008-07-28T11:32:38-04:0075242http://forums.silverlight.net//p/21234/75242.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p>&nbsp;From my own experience, yes, it will run if you put the content on a webserver. When running in the local security zone, something goes wrong. If it is anything like Flash (I'm a bit of a Silverlight noob), mixing local and online file access is not allowed.<br> </p> 2008-07-28T11:36:54-04:0075244http://forums.silverlight.net//p/21234/75244.aspx/1?Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>spender</h4> <p>&nbsp;From my own experience, yes, it will run if you put the content on a webserver. When running in the local security zone, something goes wrong. If it is anything like Flash (I'm a bit of a Silverlight noob), mixing local and online file access is not allowed.<br> </p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Thanks for your quick response! </p> <p>Something weird happened when I tried the things you wrote. First i tried with mms-stream and I got no error and no sound. Then I tried with Http and got a millisecond of sound and then it stopped. I tried to switch back to mms and now with&nbsp;both that and http i get the same error as I got in the beginning...</p> <p>I'll try a webserver...</p> 2008-07-28T11:41:08-04:0075246http://forums.silverlight.net//p/21234/75246.aspx/1?Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Problems loading server-side http stream in MediaElement <p>&nbsp;let me know how you get on... if you can get it working too, I'll make a more detailed post on our blog.</p> <p>&nbsp;</p> <p>thanks. <br> </p> 2008-07-28T11:45:10-04:0075248http://forums.silverlight.net//p/21234/75248.aspx/1?Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>spender</h4> <p>&nbsp;let me know how you get on... if you can get it working too, I'll make a more detailed post on our blog.</p> <p>thanks. <br> </p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>I'll do so if i get it up and running... [:)]</p> 2008-07-28T11:51:30-04:0075548http://forums.silverlight.net//p/21234/75548.aspx/1?Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Problems loading server-side http stream in MediaElement <p>Okay I got an idea when trying today to get it running on the developing laptop... AND I GOT IT STREAMING! [H]</p> <p>I did the following:</p> <ol> <li> <div>I made a status TextBlock where I print out messages about the stream.</div> </li><li> <div>I set the source of the MediaElement in code-behind like this (note that I&nbsp;a have used the tricks from spender): _MePlayMusic.Source = <font color="#0000ff">new</font> <font color="#2b91af">Uri</font>(<font color="#a31515">&quot;mms://IPADDRESS:PORTNUMBER/;&quot;</font>, <font color="#2b91af">UriKind</font>.Absolute);</div> </li><li> <div>Use the CurrentStateEvent on the MediaElement to print out the state&nbsp;that the MediaElement is in to find out what it's doing (with a switch statement and the previously mentioned TextBlock).</div> </li><li> <div>Change the BufferingTime of the MediaElement to 10 or 20 seconds.</div> </li></ol> <p>... and out of the blue it started streaming from the server.... [:D] It doesn't start streaming every time I open it and when it doesn't start it has a state of &quot;Paused&quot; (I didn't think that was possible&nbsp;with a server-side stream and Silverlight but nevermind...)</p> <p>My idea, without having tried it, the problem is that it's not run from a webserver. I have the security settings&nbsp;in Vista&nbsp;accused&nbsp;of giving me the problems opening the stream...</p> 2008-07-29T12:23:03-04:0075553http://forums.silverlight.net//p/21234/75553.aspx/1?Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Problems loading server-side http stream in MediaElement <p>great news... glad i could help<br> </p> 2008-07-29T12:39:12-04:0075556http://forums.silverlight.net//p/21234/75556.aspx/1?Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Problems loading server-side http stream in MediaElement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>spender</h4> <p>great news... glad i could help<br> </p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Thanks for your help! I had never figured out&nbsp;the tricks you wrote about myself. Hope you can use this post in your blog so people who get this problem can get help.</p> <p>Do you or anyone else have an idea of why it stops with the state of &quot;Paused&quot; when trying to start the stream?</p> 2008-07-29T12:48:23-04:0075564http://forums.silverlight.net//p/21234/75564.aspx/1?Re+Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Re: Problems loading server-side http stream in MediaElement <p>&nbsp;not really sure about that one. I do all the set up programmatically in c#, so I have something like this...</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Page() //constructor<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponent();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Source = new Uri(&quot;mms://SCSTREAM.NET/;&quot;);<br> &nbsp;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.MediaOpened &#43;= new RoutedEventHandler(media_MediaOpened);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.MediaFailed &#43;= media_MediaFailed;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Play();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void media_MediaOpened(object sender, RoutedEventArgs e)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.WriteLine(media.CanSeek);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void media_MediaFailed(object sender, ExceptionRoutedEventArgs e)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.WriteLine(e.ErrorException.Message);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;</p> <p>it seems to work fine, although I have only run the code about three times, so I may be wrong<br> </p> 2008-07-29T13:07:16-04:0076248http://forums.silverlight.net//p/21234/76248.aspx/1?Re+Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Re: Problems loading server-side http stream in MediaElement <p>I've still got problems with this. I have tried it on a webserver and I still can't get the stream to start.</p> <p>It starts to open the stream, closes it, opens it, plays for a millisecond and then pauses...</p> <p>&nbsp;</p> <p>What can I do to get it working? I'm realy out of ideas...</p> 2008-07-31T11:07:12-04:0076634http://forums.silverlight.net//p/21234/76634.aspx/1?Re+Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Re: Problems loading server-side http stream in MediaElement <p>I solved the problem!&nbsp;[:)] It all work perfectly now! It turned out that the MediaElement couldn't load the stream in Mp3-format (I think it was in Mp3PRO-format). When using an WMA-stream it worked...</p> <p>Thanks to all for your help!</p> 2008-08-01T10:54:13-04:00102580http://forums.silverlight.net//p/21234/102580.aspx/1?Re+Re+Re+Re+Re+Problems+loading+server+side+http+stream+in+MediaElementRe: Re: Re: Re: Re: Problems loading server-side http stream in MediaElement <p>Hello everyone,</p> <p>This problem for me it has not been solved. The media element is being paused after 1 milisecond in IE. In Firefox it works well. Has anyone got a solution? </p> <p>It has been tested in RC0. Is there a way to contact the development team to keep that in mind ?</p> <p>Tha strange this is that is works in Firefox like a charm but in IE and Safari is being paused. I haven't tried it in Opera though. Any thoughts? I have tried everything above...<br> </p> 2008-10-04T08:23:42-04:00