Getting Startedhttp://forums.silverlight.net//14.aspx/1?Getting+StartedThe perfect forum for asking the basic questions. No question too simple!Mon, 01 Jan 0001 00:00:00 -050014138545http://forums.silverlight.net//p/53437/138545.aspx/1?Sound+thats+loopsSound thats loops <p>Hi,</p> <p>I would like a mp3 to play when the page loads and then to continue looping. I am not quite sure how to go about doing this, does anyone have an ideas for me or an URL that I can check it out at?</p> <p>Thanks</p> 2008-11-27T12:54:42-05:00138551http://forums.silverlight.net//p/53437/138551.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>as i remember there is a media ended event</p> <p>there you can repostion to start and call play()</p> 2008-11-27T13:04:00-05:00138573http://forums.silverlight.net//p/53437/138573.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>Hi Hannes,</p> <p>Thanks for your reply to this post. Maybe I jumped the gun slightly, I have not got the sound working yet. Looping it would be the next step in the process. I have added the media element to my canvas, then in the C# file I have tried to reference it in the same way that I would a storyboard but it does not work. Is this the correct way or should I be trying this another way?</p> <font size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">void</font></font><font size="2"> Page_Loaded(</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">object</font></font><font size="2"> sender, </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">RoutedEventArgs</font></font><font size="2"> e)</font></font><font size="2"> <p>{</p> <p></font>track_mp3.Play(); </p> <p>}</p> <p>Thanks</p> 2008-11-27T13:45:46-05:00138609http://forums.silverlight.net//p/53437/138609.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>Here you go.</p> <p>&nbsp;&lt;MediaElement x:Name=<span style="color:maroon">&quot;media&quot;</span> Source=<span style="color:maroon">&quot;xbox.wmv&quot;</span> <br> &nbsp;&nbsp;&nbsp; Width=<span style="color:maroon">&quot;300&quot;</span> Height=<span style="color:maroon">&quot;300&quot;</span> /&gt;<br> </p> <p>By default, the media that is defined by the <span><a id="ctl00_rs1_mainContentContainer_ctl26" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source(VS.95).aspx"><font color="#0033cc">Source</font></a></span> property plays immediately after the <span><span class="selflink"><strong>MediaElement</strong></span></span> object has loaded. To suppress the media from starting automatically, set the <span><a id="ctl00_rs1_mainContentContainer_ctl27" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.autoplay(VS.95).aspx"><font color="#800080">AutoPlay</font></a></span> property to <span><span class="input"><strong>false or </strong>in your case set it to true</span></span>.</p> <p>and if this <strong>post</strong> was <strong>helpful</strong> then <strong>please 'Mark as Answer' - many thanks</strong></p> <p>Sharker Khaleed Mahmud (MCPD)<br> Software Developer</p> <p>This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.</p> 2008-11-27T15:35:45-05:00141485http://forums.silverlight.net//p/53437/141485.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>Hi Vyfster,</p> <p>To make the video display automatically, we need to set its AutoPlay to &quot;Ture&quot;. &nbsp;</p> <p>To make it loop, we need to replay the video on MediaEnded event.&nbsp; For example, <br> </p> <p>&nbsp;&lt;MediaElement x:Name=&quot;media&quot; Source=&quot;midnight.wmv&quot;&nbsp; Width=&quot;300&quot; Height=&quot;300&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot; Grid.ColumnSpan=&quot;3&quot; AutoPlay=&quot;True&quot; MediaEnded=&quot;PlayMedia&quot;/&gt;</p> <p>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void PlayMedia(object sender, RoutedEventArgs e) <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Stop();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Play(); <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p> <p>Best regards,</p> <p>Jonathan <br> </p> <p>&nbsp;<br> </p> 2008-12-03T08:49:42-05:00145343http://forums.silverlight.net//p/53437/145343.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>Any release date for a silverlight patch to correct the short sound problem by the way ?</p> <p>&nbsp;</p> 2008-12-10T11:06:25-05:00156616http://forums.silverlight.net//p/53437/156616.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <p>Hi Jonathan,</p> <p>&nbsp;I went to sleep on this post and have only picked it upi gain now. I have managed to get the media element playing, it was a little tricky at first but I understand how it is done now. It is added from the asset library and then dragged and dropped onto the stage. I was looking for an actual media element. The second part of your post has me confused though. Where is it added into the code behind file? I keep on getting build error's so I must be adding it incorrectly.</p> <p>/* where in the code behind file does this code get added? */&nbsp;&nbsp;</p> <p>private void PlayMedia(object sender, RoutedEventArgs e) <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Stop();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media.Play(); <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p> <p>&nbsp;</p> <p>Thanks for your input so far.</p> 2009-01-06T12:33:30-05:00156885http://forums.silverlight.net//p/53437/156885.aspx/1?Re+Re+Sound+thats+loopsRe: Re: Sound thats loops Hook a &quot;Completed&quot; handle to your media element with <br> <br> this.BikiniGirls.MediaEnded &#43;= new RoutedEventHandler(BikiniGirls_MediaEnded);<br> <br> ^ do that somewhere in initialization-- and when the girls stop dancing on the trampoline it will automagically call this function <br> <br> private void BikiniGirls_MediaEnded(object sender, RoutedEventArgs e)<br> { <br> Bikinigirls.stop();<br> BikiniGirls.Position = TimeSpan.FromSeconds(0);<br> Bikinigirls.Play();<br> }<br> <br> note: this only will work for dancing bikini girls, i've never tested it with music. 2009-01-06T20:45:36-05:00156888http://forums.silverlight.net//p/53437/156888.aspx/1?Re+Re+Re+Sound+thats+loopsRe: Re: Re: Sound thats loops LOL I just noticed that Jonathan did the same thing. But he left out the Position which I've always had to set when looking at bikinigirls. So I'm more specialer. I love you Jonathan.<br> <br> Seriously though, set the Position to 0 and then play it and it will work. 2009-01-06T20:49:44-05:00157191http://forums.silverlight.net//p/53437/157191.aspx/1?Re+Sound+thats+loopsRe: Sound thats loops <font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>Thanks for all the help guys. </p> <p>This is what finally worked. I just left off the&nbsp;&nbsp;track_mp3.Stop(); and it now loops. Previously it played once and then stopped.</p> <p>&nbsp;</p> void</font></font><font size="2"> track_mp3_MediaEnded(</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">object</font></font><font size="2"> sender, </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">RoutedEventArgs</font></font><font size="2"> e)</font><font size="2"> <p>{</p> </font><font size="2">track_mp3.Play();</font><font size="2"> <p>track_mp3.Position = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">TimeSpan</font></font><font size="2">.FromSeconds(0);</p> <p>}</p> </font> 2009-01-07T11:37:20-05:00