Ejemplo n.º 1
0
        public void SetVideoSurface(IVideoSurface videoSurface)
        {
            if (!(videoSurface is VideoSurface))
            {
                throw new ArgumentException("Not a valid video surface");
            }

            var canvas = (VideoSurface)videoSurface;

            RenderSurface = canvas;

            var size = new Size(canvas.ActualWidth, canvas.ActualHeight);

            _player.SetSurfaceSize(size);

            var compositor = ElementCompositionPreview.GetElementVisual(canvas).Compositor;
            var surface    = _player.GetSurface(compositor);

            _spriteVisual      = compositor.CreateSpriteVisual();
            _spriteVisual.Size =
                new Vector2((float)canvas.ActualWidth, (float)canvas.ActualHeight);

            CompositionBrush brush = compositor.CreateSurfaceBrush(surface.CompositionSurface);

            _spriteVisual.Brush = brush;

            var container = compositor.CreateContainerVisual();

            container.Children.InsertAtTop(_spriteVisual);

            ElementCompositionPreview.SetElementChildVisual(canvas, container);
        }
Ejemplo n.º 2
0
 public void Open(IVideoSurface playbackSurface, string filePath, DateTime correlationStartTime)
 {
     filePath = filePath.Replace("\"", "");
     lock (_lock)
     {
         CreatePlayer(playbackSurface);
         OpenFile(filePath, correlationStartTime);
     }
 }
        public void SetVideoSurface(IVideoSurface videoSurface)
        {
            if (!(videoSurface is VideoSurface))
            {
                throw new ArgumentException("Not a valid video surface");
            }

            var canvas = (VideoSurface)videoSurface;

            RenderSurface = canvas;
        }
        public void SetVideoSurface(IVideoSurface videoSurface)
        {
            var view = ((VideoSurface)videoSurface);

            if (view == null)
            {
                throw new ArgumentException("VideoSurface must be a UIView");
            }
            RenderSurface = videoSurface;
            _videoLayer   = AVPlayerLayer.FromPlayer(Player);
            view.Layer.AddSublayer(_videoLayer);
            _videoLayer.Frame = view.Frame;
            SetAspectMode(VideoAspectMode.AspectFit);
        }
Ejemplo n.º 5
0
        public void SetVideoSurface(IVideoSurface videoSurface)
        {
            var view = (VideoSurface)videoSurface;

            if (view == null)
            {
                throw new ArgumentException("VideoSurface must be a UIView");
            }

            RenderSurface            = videoSurface;
            _videoLayer              = AVPlayerLayer.FromPlayer(Player);
            _videoLayer.Frame        = view.Frame;
            _videoLayer.VideoGravity = AVLayerVideoGravity.ResizeAspect;
            view.Layer.AddSublayer(_videoLayer);
        }
Ejemplo n.º 6
0
        private void CreatePlayer(IVideoSurface playbackSurface)
        {
            var surface = playbackSurface.GetSurfaceControl();

            if (IsConnected())
            {
                if (_surface == surface)
                {
                    return;
                }
                Close();
            }

            if (_surface != null)
            {
                _surface.Paint       -= SurfacePaint;
                _surface.SizeChanged -= SurfaceSizeChanged;
            }

            try
            {
                _playerPointer = Marshal.AllocHGlobal(IntPtr.Size);
                CppAssembly.CreatePlayer(out _playerPointer, surface.Handle, Handle, out var invokeResult);
                if (invokeResult != 0)
                {
                    throw new InvalidOperationException($"Failed to connect to player #{invokeResult}.");
                }
                _surface              = surface;
                _surface.Paint       += SurfacePaint;
                _surface.SizeChanged += SurfaceSizeChanged;
            }
            catch (Exception)
            {
                DisposePointerToPlayer();
                throw;
            }
        }
 private void SetVideoSurface(IVideoSurface videoSurface)
 {
     Add(videoSurface as _View);
     ((_View)videoSurface).Frame = this.Frame;
 }
Ejemplo n.º 8
0
 private void SetVideoSurface(IVideoSurface videoSurface)
 {
     Child = videoSurface as UIView;
     ((UIView)videoSurface).Frame = this.Frame;
 }
Ejemplo n.º 9
0
 private void SetVideoSurface(IVideoSurface videoSurface)
 {
     this.Child = VisualTreeHelper.AdaptNative(videoSurface as SurfaceView);
 }
Ejemplo n.º 10
0
 private void SetVideoSurface(IVideoSurface videoSurface)
 {
     this.Child = videoSurface as SurfaceView;
 }