WOW ty so much<br><br>at least I wasn&#39;t to far off :-P<br><br>again ty, you saved me from giving up on Silverlight :D<br><br><br><div class="gmail_quote">On Mon, Jan 11, 2010 at 1:37 PM, Jimmy Schementi <span dir="ltr">&lt;<a href="mailto:Jimmy.Schementi@microsoft.com">Jimmy.Schementi@microsoft.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">You can attach Visual Studio to a running Silverlight process, and breakpoints will be hit in your Silverlight code if you set the debug flag in the HTML page hosting Silverlight:</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">      &lt;param name=&quot;initParams&quot; value=&quot;<b>debug=true</b>, reportErrors=errorLocation, console=true&quot; /&gt;</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">This only works if VS 2008 SP1 has the Silverlight 3 Tools (<a href="http://www.microsoft.com/downloads/details.aspx?familyid=9442b0f2-7465-417a-88f3-5e7b5409e9dd&amp;displaylang=en" target="_blank">http://www.microsoft.com/downloads/details.aspx?familyid=9442b0f2-7465-417a-88f3-5e7b5409e9dd&amp;displaylang=en</a>) installed, or you’re using VS 2010 (which support Silverlight out-of-the-box).</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">~js</span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<div style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;"><div><div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;"> Jimmy Schementi <br><b>Sent:</b> Monday, January 11, 2010 1:27 PM<div class="im"><br><b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a><br>
</div><b>Subject:</b> RE: [IronPython] Silverlight code need help (Repost)</span></p></div></div><div><div></div><div class="h5"><p class="MsoNormal"> </p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">The error you’re probably seeing is “AttributeError: &#39;Duration&#39; object has no attribute &#39;CurrentState&#39;,” correct (line highlighted below)?. This is because MediaElement.NaturalDuration gives you a System.Windows.Duration object (<a href="http://msdn.microsoft.com/en-us/library/system.windows.duration%28VS.95%29.aspx%29" target="_blank">http://msdn.microsoft.com/en-us/library/system.windows.duration(VS.95).aspx)</a>, which in-fact doesn’t have a “CurrentState” member. However, MediaElement has a “CurrentState” member, so I think you intending that line to read “ if self.video. CurrentState == MediaElementState.Playing:”. You’ll also need to add “from System.Windows.Media import MediaElementState” to make sure MediaElementState is available.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Let me know if you have any other issues.</span></p><p class="MsoNormal">
<span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><div style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;">
<div><div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;"><p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;"> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Andrew Evans<br>
<b>Sent:</b> Monday, January 11, 2010 1:04 PM<br><b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a><br><b>Subject:</b> [IronPython] Silverlight code need help (Repost)</span></p>
</div></div><p class="MsoNormal"> </p><p class="MsoNormal">I am having problems with my code. I am not sure how to debug silverlight. I receive no error messages, but this is what happens. When this app runs it starts for a second then disappears I am not sure where I am going wrong, any ideas? Perhaps in the threading? <br>
<br>I am not a C# programmer but I am doing my best to find examples to compare to so I can translate into python<br><br><br>I would really appreciate any help *Cheers Andrew<br><br><br>Here is the full code hope that&#39;s alright :D</p>
<div><p class="MsoNormal"><br><br><br>from System.Windows import Application<br>from System.Windows.Controls import MediaElement<br>from System.Windows.Controls import Button, Orientation, StackPanel, Slider<br>from System import Uri, UriKind    <br>
from System.Windows.Media.Imaging import BitmapImage<br>from System.Windows.Threading import *</p></div><p class="MsoNormal">from System import TimeSpan<br>class Gui():<br>    def __init__(self):<br><br>        self.main = StackPanel() <br>
<br>        self.layer1 = StackPanel() <br>        self.layer1.Orientation = Orientation.Horizontal<br><br>        self.stopB = Button()<br>        self.stopB.Width = 25<br>        self.stopB.Height = 20<br>        self.stopB.Content = BitmapImage(Uri(&quot;stop.jpg&quot;, UriKind.Relative))<br>
<br>        self.pauseB = Button()<br>        self.pauseB.Width = 25<br>        self.pauseB.Height = 20<br>        self.pauseB.Content = BitmapImage(Uri(&quot;pause.jpg&quot;, UriKind.Relative))<br>        <br>        self.playB = Button()<br>
        self.playB.Width = 25<br>        self.playB.Height = 20<br>        self.playB.Content = BitmapImage(Uri(&quot;play.jpg&quot;, UriKind.Relative))<br>        <br>        # Assign Buttons to Functions<br>        self.stopB.Click += self.StopPlay<br>
        self.pauseB.Click += self.PausePlay<br>        self.playB.Click += self.StartPlay</p><div><p class="MsoNormal"><br><br>        #add a video slider<br>        self.myslide = Slider()<br>        self.myslide.Width = 250<br>
        </p></div><p class="MsoNormal">        # Add buttons to sub stack panel<br>        self.layer1.Children.Add(self.</p><div><p class="MsoNormal">stopB)<br>        self.layer1.Children.Add(self.pauseB)</p><div><p class="MsoNormal">
<br>        self.layer1.Children.Add(self.myslide)</p></div><p class="MsoNormal">        self.layer1.Children.Add(self.playB)<br><br>        # create new sub stack panel<br>        self.layer2 = StackPanel()<br>        self.layer2.Orientation = Orientation.Vertical</p>
<div><p class="MsoNormal"><br><br>        #create Media Element<br>        self.video = MediaElement()</p></div><p class="MsoNormal">        self.source = Uri(&quot;counter.wmv&quot;, UriKind.Relative)<br>        self.video.Volume = 0.4<br>
        self.video.Source = self.source<br>        self.video.Width = 450<br>        self.video.Height = 400<br>        self.video.CurrentStateChanged += self.videoChanged<br><br>        self.timer = DispatcherTimer()<br>
        self.timer.Interval = TimeSpan.FromMilliseconds(45)<br>        self.timer.Tick += self.MyTimeToTick<br>        <br><br><br>        # Add media Element to Sub Stack panel<br>        self.layer2.Children.Add(self.video)<br>
<br>        # Add sub stack panels to place holde stack panel<br>        self.main.Children.Add(self.layer1)<br>        self.main.Children.Add(self.layer2)<br><br>        # Load the UI<br>        Application.Current.RootVisual = self.main     </p>
<div><p class="MsoNormal"><br>    def MyTimeToTick(self, s, e):<br><span style="color: red;">        </span><span style="color: black;">if self.video.NaturalDuration.TimeSpan.TotalSeconds &gt; 0:<br></span>            self.myslide.Value = self.video.Position.TotalSeconds / self.video.NaturalDuration.TimeSpan.TotalSeconds<br>
<br><br>    def videoChanged(self, s, e):</p></div><p class="MsoNormal"><span style="color: red;">        <span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">if self.video.NaturalDuration.CurrentState == MediaElementState.Playing:</span></span></p>
<div><p class="MsoNormal"><br>            self.timer.Start()<br>        else:<br>            self.timer.Stop()<br>##<br>##        </p></div><p class="MsoNormal">    def StopPlay(self, s, e):<br>        # stop the video<br>
        self.video.Stop()<br>        <br>    def PausePlay(self, s, e):<br>        #pause the video<br>        self.video.Pause()<br>        <br>    def StartPlay(self, s, e):<br>        #play the video<br>        self.video.Play()<br>
<br>gui = Gui()<br>gui</p></div></div></div></div></div></div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>