Commit 11045053 authored by Martin Finkel's avatar Martin Finkel

VideoView is a UIView, not a UIViewController

parent 52abb3c9
using LibVLCSharp.Platforms.iOS;
using LibVLCSharp.Shared;
using UIKit;
namespace LibVLCSharp.iOS.Sample
{
public class ViewController : VideoView
public class ViewController : UIViewController
{
VideoView _videoView;
public override void ViewDidLoad()
{
AttachView(View);
_videoView = new VideoView();
MediaPlayer.Play(new Media(Instance, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
Media.FromType.FromLocation));
View = _videoView;
_videoView.Attach();
_videoView.MediaPlayer.Play(new Media(_videoView.Instance, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
}
}
}
\ No newline at end of file
using System;
using LibVLCSharp.Shared;
using UIKit;
namespace LibVLCSharp.Platforms.iOS
{
public abstract class VideoView : UIViewController, IVideoView
public class VideoView : UIView, IVideoView
{
protected VideoView()
public VideoView()
{
Instance = new Instance();
MediaPlayer = new MediaPlayer(Instance);
......@@ -15,19 +17,10 @@ namespace LibVLCSharp.Platforms.iOS
public MediaPlayer MediaPlayer { get; }
public Instance Instance { get; }
public void AttachView(object surface)
{
if(surface == null) throw new NullReferenceException(nameof(surface));
public void Attach(UIView view) => MediaPlayer.NsObject = view.Handle;
if (surface is UIView uiView)
{
MediaPlayer.NsObject = uiView.Handle;
}
}
public void Attach() => MediaPlayer.NsObject = Handle;
public void DetachView()
{
MediaPlayer.NsObject = IntPtr.Zero;
}
public void Detach() => MediaPlayer.NsObject = IntPtr.Zero;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment