Program.cs 1.38 KB
Newer Older
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
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
using Gtk;
using LibVLCSharp.Shared;

namespace LibVLCSharp.GTK.Sample
{
    public class Program
    {
        public static void Main()
        {
            Core.Initialize();

            // Initializes the GTK# app
            Application.Init();

            using (var libvlc = new LibVLC())
            using (var mediaPlayer = new MediaPlayer(libvlc))
            {
                // Create the window in code. This could be done in glade as well, I guess...
                Window myWin = new Window("LibVLCSharp.GTK.Sample");
                myWin.Resize(800, 450);

                // Creates the video view, and adds it to the window
                VideoView videoView = new VideoView { MediaPlayer = mediaPlayer };
                myWin.Add(videoView);

                //Show Everything
                myWin.ShowAll();

                //Starts playing
                using (var media = new Media(libvlc,
                    "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
Martin Finkel's avatar
Martin Finkel committed
32
                    FromType.FromLocation))
Jérémy VIGNELLES's avatar
Jérémy VIGNELLES committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
                {
                    mediaPlayer.Play(media);
                }

                myWin.DeleteEvent += (sender, args) => 
                {
                    mediaPlayer.Stop();
                    videoView.Dispose(); 
                    Application.Quit(); 
                };
                Application.Run();
            }
        }
    }
}