I have debugged some of the code now it loads for a second then it some how
refreshes and disappears not sure what I am doing wrong

Any ideas

Cheers

Here is the full code hope that's alright :D


from System.Windows import Application
from System.Windows.Controls import MediaElement
from System.Windows.Controls import Button, Orientation, StackPanel, Slider
from System import Uri, UriKind
from System.Windows.Media.Imaging import BitmapImage
from System.Windows.Threading import *
from System import TimeSpan
class Gui():
    def __init__(self):

        self.main = StackPanel()

        self.layer1 = StackPanel()
        self.layer1.Orientation = Orientation.Horizontal

        self.stopB = Button()
        self.stopB.Width = 25
        self.stopB.Height = 20
        self.stopB.Content = BitmapImage(Uri("stop.jpg", UriKind.Relative))

        self.pauseB = Button()
        self.pauseB.Width = 25
        self.pauseB.Height = 20
        self.pauseB.Content = BitmapImage(Uri("pause.jpg",
UriKind.Relative))

        self.playB = Button()
        self.playB.Width = 25
        self.playB.Height = 20
        self.playB.Content = BitmapImage(Uri("play.jpg", UriKind.Relative))

        # Assign Buttons to Functions
        self.stopB.Click += self.StopPlay
        self.pauseB.Click += self.PausePlay
        self.playB.Click += self.StartPlay

        #add a video slider
        self.myslide = Slider()
        self.myslide.Width = 250

        # Add buttons to sub stack panel
        self.layer1.Children.Add(self.stopB)
        self.layer1.Children.Add(self.pauseB)
        self.layer1.Children.Add(self.myslide)
        self.layer1.Children.Add(self.playB)

        # create new sub stack panel
        self.layer2 = StackPanel()
        self.layer2.Orientation = Orientation.Vertical

        #create Media Element
        self.video = MediaElement()
        self.source = Uri("counter.wmv", UriKind.Relative)
        self.video.Volume = 0.4
        self.video.Source = self.source
        self.video.Width = 450
        self.video.Height = 400
        self.video.CurrentStateChanged += self.videoChanged

        self.timer = DispatcherTimer()
        self.timer.Interval = TimeSpan.FromMilliseconds(45)
        self.timer.Tick += self.MyTimeToTick



        # Add media Element to Sub Stack panel
        self.layer2.Children.Add(self.video)

        # Add sub stack panels to place holde stack panel
        self.main.Children.Add(self.layer1)
        self.main.Children.Add(self.layer2)

        # Load the UI
        Application.Current.RootVisual = self.main

    def MyTimeToTick(self, s, e):
        if self.video.NaturalDuration.TimeSpan.TotalSeconds > 0:
            self.myslide.Value = self.video.Position.TotalSeconds /
self.video.NaturalDuration.TimeSpan.TotalSeconds


    def videoChanged(self, s, e):
        if self.video.NaturalDuration.CurrentState ==
MediaElementState.Playing:
            self.timer.Start()
        else:
            self.timer.Stop()
##
##
    def StopPlay(self, s, e):
        # stop the video
        self.video.Stop()

    def PausePlay(self, s, e):
        #pause the video
        self.video.Pause()

    def StartPlay(self, s, e):
        #play the video
        self.video.Play()

gui = Gui()
gui
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to