Exemplo n.º 1
0
        public void Update(AnimatedVisualPlayer player)
        {
            if (_animation == null)
            {
                _animation = new LOTAnimationView();
                SetProperties();
#if __IOS__
                player.Add(_animation);
#else
                player.AddSubview(_animation);
#endif
            }
            else
            {
                SetProperties();
            }

            void SetProperties()
            {
                var path = UriSource?.PathAndQuery ?? "";

                if (_lastPath != path)
                {
                    _animation.SetAnimationNamed(path);
                    _lastPath = path;
                }

                switch (player.Stretch)
                {
                case Windows.UI.Xaml.Media.Stretch.None:
                    _animation.ContentMode = _ViewContentMode.Center;
                    break;

                case Windows.UI.Xaml.Media.Stretch.Uniform:
                    _animation.ContentMode = _ViewContentMode.ScaleAspectFit;
                    break;

                case Windows.UI.Xaml.Media.Stretch.Fill:
                    _animation.ContentMode = _ViewContentMode.ScaleToFill;
                    break;

                case Windows.UI.Xaml.Media.Stretch.UniformToFill:
                    _animation.ContentMode = _ViewContentMode.ScaleAspectFill;
                    break;
                }

                _animation.AnimationSpeed = (nfloat)player.PlaybackRate;

                if (player.AutoPlay && !_isPlaying)
                {
                    Play(true);
                }
            }

            _player = player;
        }