ViewController.cs 1.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
using System;

using AppKit;
using Foundation;

using LibVLCSharp.Platforms.Mac;
using LibVLCSharp.Shared;

namespace LibVLCSharp.Mac.Sample
{
    public partial class ViewController : NSViewController
    {
        VideoView _videoView;
Martin Finkel's avatar
Martin Finkel committed
14 15
        LibVLC _libVLC;
        Shared.MediaPlayer _mediaPlayer;
16 17 18 19 20 21 22 23 24

        public ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

25 26
            Core.Initialize();

Martin Finkel's avatar
Martin Finkel committed
27 28 29 30
            _libVLC = new LibVLC();
            _mediaPlayer = new Shared.MediaPlayer(_libVLC);

            _videoView = new VideoView { MediaPlayer = _mediaPlayer };
31 32 33

            View = _videoView;

Martin Finkel's avatar
Martin Finkel committed
34
            _videoView.MediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        }

        public override NSObject RepresentedObject
        {
            get
            {
                return base.RepresentedObject;
            }
            set
            {
                base.RepresentedObject = value;
                // Update the view, if already loaded.
            }
        }
   }
Martin Finkel's avatar
Martin Finkel committed
50
}