Esempio n. 1
0
 private void CleanPlayerItem()
 {
     _PlayerItem.RemoveObserver(this, _status);
     _PlayerItem.RemoveObserver(this, _error);
     _Asset.Dispose();
     _PlayerItem.Dispose();
 }
Esempio n. 2
0
 protected override void OnElementChanged(ElementChangedEventArgs <VideoPlayer> e)
 {
     base.OnElementChanged(e);
     if (Control == null)
     {
         _timer          = new Timer(TimeSpan.FromSeconds(1).TotalMilliseconds);
         _timer.Elapsed += _timer_Elapsed;
     }
     if (e.OldElement != null)
     {
         _timer?.Stop();
         _timer?.Dispose();
         _timer = null;
         _asset?.Dispose();
         _asset = null;
         _playerItem?.Dispose();
         _playerItem = null;
         _player?.Dispose();
         _player = null;
         _playerLayer?.Dispose();
         _playerLayer = null;
     }
     if (e.NewElement != null)
     {
     }
 }
Esempio n. 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <CustomSlider> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                seekBar = new UISlider();
                SetNativeControl(seekBar);
            }

            if (e.OldElement != null)
            {
                if (player != null)
                {
                    player.Dispose();
                    playerItem.Dispose();
                    player     = null;
                    playerItem = null;
                }

                /*
                 * player.RemoveObserver(this, "status");
                 *
                 * player.CurrentItem?.RemoveObserver(this, (NSString)"playbackBufferEmpty");
                 * player.CurrentItem?.RemoveObserver(this, (NSString)"playbackLikelyToKeepUp");
                 */
            }

            if (e.NewElement != null)
            {
                slider = e.NewElement;

                seekBar.MaximumTrackTintColor = Color.FromHex(slider.MaximumTrackTintColor).ToUIColor();
                seekBar.MinimumTrackTintColor = Color.FromHex(slider.MinimumTrackTintColor).ToUIColor();
                //seekBar.ThumbTintColor = Color.FromHex("#827DCE").ToUIColor();
                seekBar.SetThumbImage(UIImage.FromFile(slider.TintImageFileName), UIControlState.Normal);
                seekBar.Continuous = false;

                seekBar.SizeToFit();

                _fitSize = Control.Bounds.Size;
                // except if your not running iOS 7... then it fails...
                if (_fitSize.Width <= 0 || _fitSize.Height <= 0)
                {
                    _fitSize = new SizeF(22, 22); // Per the glorious documentation known as the SDK docs
                }
                //if(e.OldElement != null)
                //	slider.ClickedButton -= Slider_ClickedButton;
                slider.ClickAction       = UpdatePlaying;
                slider.StopPlayingAction = StopPlayingAction;
                // Control.ScaleY = 5;
                slider.CommandImageFileName = slider.PlayImageFileName;
                slider.CommandText          = "Play";
                //slider.AudioService.IsStoped = true;
                slider.TimeLeftString = string.Format("{0:mm\\:ss}", TimeSpan.FromMilliseconds(slider.FileDuration ?? 0));
            }

            seekBar.TouchDown     += Control_TouchDown;
            seekBar.TouchUpInside += Control_TouchUpInside;
        }
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     _player?.Dispose();
     _playerLayer?.Dispose();
     _playerItem?.Dispose();
     _asset?.Dispose();
     _timeObserver?.Dispose();
 }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (player != null)
            {
                player.ReplaceCurrentItemWithPlayerItem(null);
            }
            player?.Dispose();
            playerItem?.Dispose();
            _playerViewController?.Dispose();
        }
        private void PlatformDispose(bool disposing)
        {
            if (Player != null)
            {
                Player.Dispose();
                Player = null;
            }

            if (movie != null)
            {
                movie.Dispose();
                movie = null;
            }
        }
Esempio n. 7
0
        private void DisposeChildren()
        {
            player?.Pause();

            playerController?.RemoveFromParentViewController();
            playerController?.Dispose();
            playerController = null;

            player?.Dispose();
            playerItem?.Dispose();

            player = null;

            playerItem = null;
        }
Esempio n. 8
0
        private void PlatformDispose(bool disposing)
        {
            if (_sound == null)
            {
                return;
            }

            playToEndObserver.Dispose();
            playToEndObserver = null;

            _sound.Dispose();
            _sound = null;

            _player.Dispose();
            _player = null;
        }
Esempio n. 9
0
        public void LoadFromAsset(AVAsset asset)
        {
            _asset = asset;

            if (_item != null)
            {
                _playbackEndedObserver.Dispose();
                _item.Dispose();
            }

            _item = new AVPlayerItem(asset);
            _playbackEndedObserver = NSNotificationCenter.DefaultCenter.AddObserver(AVPlayerItem.DidPlayToEndTimeNotification, HandlePlaybackCompleted, _item);

            Player.Pause();
            Player.ReplaceCurrentItemWithPlayerItem(_item);
        }
Esempio n. 10
0
 private void InitPlayerForeground(string url, AVUrlAsset asset)
 {
     playEndHandle = NSNotificationCenter.DefaultCenter.AddObserver(AVPlayerItem.DidPlayToEndTimeNotification, HandlePlayEnd);
     if (Player == null)
     {
         currentItem = new AVPlayerItem(asset);
         Player      = new AVPlayer(currentItem);
         Player.AddPeriodicTimeObserver(new CMTime(1, 1), DispatchQueue.MainQueue, TimeUpdate);
     }
     else
     {
         currentItem.Dispose();
         currentItem = new AVPlayerItem(
             new AVUrlAsset(NSUrl.FromString(url),
                            new AVUrlAssetOptions(NSDictionary.FromObjectAndKey(
                                                      NSNumber.FromBoolean(true),
                                                      AVUrlAsset.PreferPreciseDurationAndTimingKey))));
         Player.ReplaceCurrentItemWithPlayerItem(currentItem);
     }
 }
Esempio n. 11
0
        protected override void Dispose(bool disposing)
        {
            if (ShouldDisposeView)
            {
                base.Dispose(disposing);
            }

            DidPlayToEndTimeObservation?.Dispose();
            DidPlayToEndTimeObservation = null;

            StatusObservation?.Dispose();
            StatusObservation = null;

            Stop();

            PlayerItem?.Dispose();
            PlayerItem = null;

            Player?.Dispose();
            Player = null;
        }
Esempio n. 12
0
 public void Open(string videoFileName)
 {
     _playerLoaded = false;
     if (_player != null)
     {
         try
         {
             _player.Pause();
             _player.Dispose();
             _player = null;
             foreach (var subView in View.VideoView.Subviews)
             {
                 subView.RemoveFromSuperview();
             }
             foreach (var subLayer in View.VideoView.Layer.Sublayers)
             {
                 subLayer.RemoveFromSuperLayer();
             }
             _playerLayer.Dispose();
             _playerItem.Dispose();
             _asset.Dispose();
         }
         catch
         {
         }
     }
     ShowPlayImage(false);
     _asset                = AVAsset.FromUrl(NSUrl.FromFilename(videoFileName));
     _playerItem           = new AVPlayerItem(_asset);
     _player               = new AVPlayer(_playerItem);
     _playerLayer          = AVPlayerLayer.FromPlayer(_player);
     _videoView            = new NSMyVideoView(new CoreGraphics.CGRect(0, 0, View.VideoView.Frame.Width, View.VideoView.Frame.Width), View.VideoView, _playerLayer);
     _videoView.WantsLayer = true;
     View.VideoView.AddSubview(_videoView);
     View.VideoView.WantsLayer = true;
     _playerLayer.Frame        = View.VideoView.Bounds;
     View.VideoView.Layer.AddSublayer(_playerLayer);
     _videoView.ResizeWithCorrectAspectRatio();
     _playerLoaded = true;
 }
Esempio n. 13
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_playbackEndedObserver != null)
                {
                    NSNotificationCenter.DefaultCenter.RemoveObserver(_playbackEndedObserver);
                    _playbackEndedObserver.Dispose();
                }

                Player?.Pause();
                PlayerLayer.Player = null;
                Player?.ReplaceCurrentItemWithPlayerItem(null);

                _item?.Dispose();
                _item = null;

                _asset?.Dispose();
                _asset = null;
            }
            base.Dispose(disposing);
        }
        /*
         *      MPMoviePlayerController _player;
         *      private List<NSObject> _observers = new List<NSObject>();
         *      protected override void OnElementChanged(ElementChangedEventArgs<CustomVideoSlider> e)
         *      {
         *          base.OnElementChanged(e);
         *          if (e.NewElement != null)
         *          {
         *              if (base.Control == null)
         *              {
         *                  _player = new MPMoviePlayerController();
         *                  _player.ScalingMode = MPMovieScalingMode.AspectFit;
         *
         *                  _player.ShouldAutoplay = true;
         *                  _player.ControlStyle = MPMovieControlStyle.None;
         *                  _player.MovieControlMode=MPMovieControlMode.Hidden;
         *                  _player.View.Frame = this.Bounds;
         *                  _player.BackgroundColor = UIColor.Clear;
         *                  base.SetNativeControl(_player.View);
         *                  var center = NSNotificationCenter.DefaultCenter;
         *                 // _observers.Add(center.AddObserver((NSString)"UIDeviceOrientationDidChangeNotification", DeviceRotated));
         *                  _observers.Add(center.AddObserver(MPMoviePlayerController.PlaybackStateDidChangeNotification, OnLoadStateChanged));
         *                  _observers.Add(center.AddObserver(MPMoviePlayerController.PlaybackDidFinishNotification, OnPlaybackComplete));
         *                  _observers.Add(center.AddObserver(MPMoviePlayerController.WillExitFullscreenNotification, OnExitFullscreen));
         *                  _observers.Add(center.AddObserver(MPMoviePlayerController.WillEnterFullscreenNotification, OnEnterFullscreen));
         *
         *
         *
         *                  bootomToolbarView = new UIView()
         *                  {
         *                      TranslatesAutoresizingMaskIntoConstraints = false,
         *                  };
         *
         *                  bootomToolbarView.AddObserver(this, (NSString)"bounds", NSKeyValueObservingOptions.New, IntPtr.Zero);
         *
         *                  gradientLayer = new CAGradientLayer();
         *                  //gradientLayer.Frame = Bounds;
         *                  gradientLayer.Colors = new CGColor[] { UIColor.Clear.CGColor, UIColor.Orange.CGColor };
         *                  gradientLayer.Locations= new NSNumber[2] {new NSNumber(0.7),new NSNumber(1.2)};
         *                  bootomToolbarView.Layer.AddSublayer(gradientLayer);
         *                  this.InsertSubviewAbove(bootomToolbarView, _player.View);
         *
         *                  labelTimeLeft = new UILabel()
         *                  {
         *                      TranslatesAutoresizingMaskIntoConstraints = false,
         *                      Text = string.Format("{0:mm\\:ss}", TimeSpan.FromMilliseconds(slider.FileDuration ?? 0)),
         *                      TextColor = UIColor.White
         *                  };
         *                  bootomToolbarView.AddSubview(labelTimeLeft);
         *
         *                  labelTimePlayed = new UILabel()
         *                  {
         *                      TranslatesAutoresizingMaskIntoConstraints = false,
         *                      Text = "00:00",
         *                      TextColor = UIColor.White
         *                  };
         *
         *                  bootomToolbarView.AddSubview(labelTimePlayed);
         *
         *                  seekBar = new UISlider()
         *                  {
         *                      TranslatesAutoresizingMaskIntoConstraints = false,
         *                  MaximumTrackTintColor = Color.LightGray.ToUIColor(),
         *                  MinimumTrackTintColor = Color.White.ToUIColor(),
         *                  ThumbTintColor = Color.FromHex("#827DCE").ToUIColor()
         *
         *              };
         *
         *                  seekBar.TouchDown += Control_TouchDown;
         *                  seekBar.TouchUpInside += Control_TouchUpInside;
         *
         *                  bootomToolbarView.AddSubview(seekBar);
         *
         *                  bootomToolbarView.RightAnchor.ConstraintEqualTo(RightAnchor).Active = true;
         *                  bootomToolbarView.LeftAnchor.ConstraintEqualTo(LeftAnchor).Active = true;
         *                  bootomToolbarView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true;
         *                  bootomToolbarView.HeightAnchor.ConstraintEqualTo(40).Active = true;
         *
         *
         *                  labelTimeLeft.RightAnchor.ConstraintEqualTo(bootomToolbarView.RightAnchor, -10).Active = true;
         *                  labelTimeLeft.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
         *                  labelTimeLeft.WidthAnchor.ConstraintEqualTo(50).Active = true;
         *                  labelTimeLeft.HeightAnchor.ConstraintEqualTo(20).Active = true;
         *
         *                  labelTimePlayed.LeftAnchor.ConstraintEqualTo(bootomToolbarView.LeftAnchor, 10).Active = true;
         *                  labelTimePlayed.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
         *                  labelTimePlayed.WidthAnchor.ConstraintEqualTo(50).Active = true;
         *                  labelTimePlayed.HeightAnchor.ConstraintEqualTo(20).Active = true;
         *
         *                  seekBar.LeftAnchor.ConstraintEqualTo(labelTimePlayed.RightAnchor, 10).Active = true;
         *                  seekBar.RightAnchor.ConstraintEqualTo(labelTimeLeft.LeftAnchor, -10).Active = true;
         *                  seekBar.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
         *                  seekBar.HeightAnchor.ConstraintEqualTo(20).Active = true;
         *
         *                  ToggleFullscreen();
         *              }
         *          }
         *          updateVideoPath();
         *          updateFullscreen();
         *      }
         *      private void DeviceRotated(NSNotification notification)
         *      {
         *          ToggleFullscreen();
         *      }
         *
         *      private void OnLoadStateChanged(NSNotification notification)
         *      {
         *
         *      }
         *
         *      private void OnPlaybackComplete(NSNotification notification) { }
         *
         *      private void OnExitFullscreen(NSNotification notification) { }
         *
         *      private void OnEnterFullscreen(NSNotification notification) { }
         *
         *      private void ToggleFullscreen()
         *      {
         *          _player.ScalingMode = MPMovieScalingMode.None;
         *          switch (UIDevice.CurrentDevice.Orientation)
         *          {
         *              case UIDeviceOrientation.Portrait:
         *                  _player?.SetFullscreen(false, true);
         *                  break;
         *              case UIDeviceOrientation.PortraitUpsideDown:
         *                  _player?.SetFullscreen(false, true);
         *                  break;
         *              case UIDeviceOrientation.LandscapeLeft:
         *                  _player?.SetFullscreen(true, true);
         *                  break;
         *              case UIDeviceOrientation.LandscapeRight:
         *                  _player?.SetFullscreen(true, true);
         *                  break;
         *          }
         *          _player.View.SetNeedsLayout();
         *          _player.View.SetNeedsDisplay();
         *      }
         *
         *      protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
         *      {
         *          base.OnElementPropertyChanged(sender, e);
         *          if (e.PropertyName == CustomVideoSlider.FileUrlProperty.PropertyName) updateVideoPath();
         *         // if (e.PropertyName == CustomVideoSlider.FullscreenProperty.PropertyName) updateFullscreen();
         *      }
         *
         *      public override void MovedToSuperview()
         *      {
         *          base.MovedToSuperview();
         *      }
         *
         *      private void updateVideoPath()
         *      {
         *          if (_player == null) return;
         *         // _player.ControlStyle = MPMovieControlStyle.Embedded;
         *          _player.ShouldAutoplay = true;
         *          _player.ContentUrl = !string.IsNullOrWhiteSpace(this.Element.FileUrl) ? NSUrl.FromString(this.Element.FileUrl) : null;
         *          _player.PrepareToPlay();
         *      }
         *
         *      private void updateFullscreen()
         *      {
         *          if (_player == null) return;
         *          _player.SetFullscreen(true, true);
         *          _player.View.SetNeedsLayout();
         *          _player.View.SetNeedsDisplay();
         *      }
         *
         *      protected override void Dispose(bool disposing)
         *      {
         *          if (this._player != null)
         *          {
         *              this._player.Dispose();
         *              this._player = null;
         *          }
         *          base.Dispose(disposing);
         *      }
         *
         */
        protected override void OnElementChanged(ElementChangedEventArgs <CustomVideoPlayer> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                //seekBar = new UISlider();
                //SetNativeControl(seekBar);
                mainView = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };
                SetNativeControl(mainView);
            }

            if (e.OldElement != null)
            {
                videoPlayerAV.RemoveObserver(this, (NSString)"videoBounds");
                bootomToolbarView.RemoveObserver(this, (NSString)"bounds");
                UIApplication.SharedApplication.SetStatusBarHidden(false, true);
                StopPlayingAction(false);
                playerItem.RemoveObserver(this, (NSString)"loadedTimeRanges");
                playerItem.Dispose();
                player.Dispose();

                Console.WriteLine("Video Finished 1");
                //playerItem = null;
                //player = null;
            }

            if (e.NewElement != null)
            {
                slider = e.NewElement;

                _fitSize = Control.Bounds.Size;
                // except if your not running iOS 7... then it fails...
                if (_fitSize.Width <= 0 || _fitSize.Height <= 0)
                {
                    _fitSize = new SizeF(22, 22); // Per the glorious documentation known as the SDK docs
                }
                slider.CommandImageFileName = "audioPlay.png";
                slider.CommandText          = "Play";
                slider.StopPlayingAction    = StopPlayingAction;

                //seekBar = new UISlider();
                //seekBar.MaximumTrackTintColor = Color.LightGray.ToUIColor();
                //seekBar.MinimumTrackTintColor = Color.White.ToUIColor();
                //seekBar.ThumbTintColor = Color.FromHex("#827DCE").ToUIColor();
                //seekBar.Continuous = false;



                // Control.ScaleY = 5;

                if (slider.FileUrl != null)
                {
                    // playerItem = AVPlayerItem.FromUrl(NSUrl.FromString("https://s3.amazonaws.com/kargopolov/kukushka.mp3"));// (asset);
                    playerItem = AVPlayerItem.FromUrl(NSUrl.FromString(slider.FileUrl));// (asset);
                    //playerItem = AVPlayerItem.FromUrl(NSUrl.FromString("https://mindcorners.blob.core.windows.net/post-attachment-videos/6412cb27-414a-435b-a480-66af5e935cb8.mov?sv=2017-04-17&sr=b&sig=gd3mn1Gai7QZHoSpx%2Fi8x%2FHfnOutACOV7WvsVblywk0%3D&se=2017-10-11T15%3A05%3A15Z&sp=r"));
                    playerItem.AddObserver(this, (NSString)"loadedTimeRanges", NSKeyValueObservingOptions.New, IntPtr.Zero);

                    player = new AVPlayer(playerItem);


                    //player.AddObserver(this, "loadedTimeRanges", NSKeyValueObservingOptions.New, null);
                    //playerLayer = AVPlayerLayer.FromPlayer(player);
                    videoPlayerAV = new AVPlayerViewController();
                    videoPlayerAV.View.BackgroundColor  = UIColor.Clear;
                    videoPlayerAV.ShowsPlaybackControls = false;


                    videoPlayerAV.AddObserver(this, (NSString)"videoBounds", NSKeyValueObservingOptions.New, IntPtr.Zero);
                    videoPlayerAV.View.Frame = Control.Frame;
                    videoPlayerAV.Player     = player;

                    UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(OnVideoTap);
                    videoView = new UIView()
                    {
                        BackgroundColor = UIColor.Clear
                    };
                    // videoView.Bounds = new CGRect(0,0,100,100);
                    videoView.AddGestureRecognizer(tapGesture);
                    //videoPlayerAV.View.AddSubview(videoView);


                    //button.CenterYAnchor.ConstraintEqualTo(videoPlayerAV.ContentOverlayView.CenterYAnchor).Active = true;
                    //button.WidthAnchor.ConstraintEqualTo(50).Active = true;
                    //button.HeightAnchor.ConstraintEqualTo(50).Active = true;



                    //videoPlayerAV.VideoGravity = AVLayerVideoGravity.ResizeAspect;

                    mainView.AddSubview(videoPlayerAV.View);
                    mainView.AddSubview(videoView);

                    videoView.TopAnchor.ConstraintEqualTo(mainView.TopAnchor).Active       = true;
                    videoView.BottomAnchor.ConstraintEqualTo(mainView.BottomAnchor).Active = true;
                    videoView.LeftAnchor.ConstraintEqualTo(mainView.LeftAnchor).Active     = true;
                    videoView.RightAnchor.ConstraintEqualTo(mainView.RightAnchor).Active   = true;
                    videoView.WidthAnchor.ConstraintEqualTo(mainView.WidthAnchor).Active   = true;
                    videoView.HeightAnchor.ConstraintEqualTo(mainView.HeightAnchor).Active = true;


                    button = new UIButton()
                    {
                        BackgroundColor = UIColor.Clear, TitleLabel = { Text = slider.CommandText }, TranslatesAutoresizingMaskIntoConstraints = false,
                    };
                    button.TouchUpInside += Button_TouchUpInside;

                    videoView.AddSubview(button);
                    button.CenterXAnchor.ConstraintEqualTo(videoView.CenterXAnchor).Active = true;
                    button.CenterYAnchor.ConstraintEqualTo(videoView.CenterYAnchor).Active = true;
                    //button.CenterXAnchor.ConstraintEqualTo(videoPlayerAV.View.CenterXAnchor).Active = true;
                    //button.CenterYAnchor.ConstraintEqualTo(videoPlayerAV.View.CenterYAnchor).Active = true;
                    button.WidthAnchor.ConstraintEqualTo(50).Active  = true;
                    button.HeightAnchor.ConstraintEqualTo(50).Active = true;



                    var center = NSNotificationCenter.DefaultCenter;
                    NSNotificationCenter.DefaultCenter.AddObserver((NSString)"UIDeviceOrientationDidChangeNotification", DeviceRotated);



                    //mainView.Layer.AddSublayer(playerLayer);
                    if (slider.AutoPlay)
                    {
                        UpdatePlaying();
                    }
                    else
                    {
                        {
                            slider.CommandImageFileName = "audioPlay.png";
                            slider.CommandText          = "Play";

                            button.Hidden = false;
                            //button.SetTitle("paused", UIControlState.Normal);
                            player.Pause();
                            isPlaying = false;
                        }

                        button.SetImage(UIImage.FromFile(slider.CommandImageFileName), UIControlState.Normal);
                    }
                }



                bootomToolbarView = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };

                bootomToolbarView.AddObserver(this, (NSString)"bounds", NSKeyValueObservingOptions.New, IntPtr.Zero);

                gradientLayer = new CAGradientLayer();
                //gradientLayer.Frame = Bounds;
                gradientLayer.Colors    = new CGColor[] { UIColor.Clear.CGColor, UIColor.Black.CGColor };
                gradientLayer.Locations = new NSNumber[2] {
                    new NSNumber(0.7), new NSNumber(1.2)
                };
                bootomToolbarView.Layer.AddSublayer(gradientLayer);
                mainView.InsertSubviewAbove(bootomToolbarView, videoPlayerAV.View);

                labelTimeLeft = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = string.Format("{0:mm\\:ss}", TimeSpan.FromMilliseconds(slider.FileDuration ?? 0)),
                    TextColor = UIColor.White
                };
                bootomToolbarView.AddSubview(labelTimeLeft);

                labelTimePlayed = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = "00:00",
                    TextColor = UIColor.White
                };

                bootomToolbarView.AddSubview(labelTimePlayed);

                seekBar = new UISlider()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    MaximumTrackTintColor = Color.LightGray.ToUIColor(),
                    MinimumTrackTintColor = Color.White.ToUIColor(),
                    ThumbTintColor        = Color.FromHex("#827DCE").ToUIColor()
                };

                seekBar.SetThumbImage(UIImage.FromFile("audioTint.png"), UIControlState.Normal);

                seekBar.TouchDown     += Control_TouchDown;
                seekBar.TouchUpInside += Control_TouchUpInside;

                bootomToolbarView.AddSubview(seekBar);

                //videoPlayerAV.View.RightAnchor.ConstraintEqualTo(RightAnchor).Active = true;
                //videoPlayerAV.View.LeftAnchor.ConstraintEqualTo(LeftAnchor).Active = true;
                //videoPlayerAV.View.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true;
                //videoPlayerAV.View.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true;


                bootomToolbarView.RightAnchor.ConstraintEqualTo(RightAnchor).Active   = true;
                bootomToolbarView.LeftAnchor.ConstraintEqualTo(LeftAnchor).Active     = true;
                bootomToolbarView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true;
                bootomToolbarView.HeightAnchor.ConstraintEqualTo(40).Active           = true;


                labelTimeLeft.RightAnchor.ConstraintEqualTo(bootomToolbarView.RightAnchor, -10).Active   = true;
                labelTimeLeft.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
                labelTimeLeft.WidthAnchor.ConstraintEqualTo(50).Active  = true;
                labelTimeLeft.HeightAnchor.ConstraintEqualTo(20).Active = true;

                labelTimePlayed.LeftAnchor.ConstraintEqualTo(bootomToolbarView.LeftAnchor, 10).Active      = true;
                labelTimePlayed.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
                labelTimePlayed.WidthAnchor.ConstraintEqualTo(50).Active  = true;
                labelTimePlayed.HeightAnchor.ConstraintEqualTo(20).Active = true;

                seekBar.LeftAnchor.ConstraintEqualTo(labelTimePlayed.RightAnchor, 10).Active       = true;
                seekBar.RightAnchor.ConstraintEqualTo(labelTimeLeft.LeftAnchor, -10).Active        = true;
                seekBar.BottomAnchor.ConstraintEqualTo(bootomToolbarView.BottomAnchor, -10).Active = true;
                seekBar.HeightAnchor.ConstraintEqualTo(20).Active = true;



                mainView.RightAnchor.ConstraintEqualTo(RightAnchor).Active = true;
                mainView.LeftAnchor.ConstraintEqualTo(LeftAnchor).Active   = true;
                // mainView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true;
                mainView.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true;

                // bootomToolbarView = new UIView();
                // //bootomToolbarView.BackgroundColor =  UIColor.Orange;
                // CAGradientLayer gradientLayer = new CAGradientLayer();
                // gradientLayer.Frame = bootomToolbarView.Frame;
                // gradientLayer.Colors = new CGColor[] {UIColor.Clear.CGColor, UIColor.Orange.CGColor};
                // bootomToolbarView.Layer.AddSublayer(gradientLayer);
                // //bootomToolbarView.BackgroundColor = new CGGradient(CGColorSpace.CreateAcesCGLinear(), new CGColor[] {UIColor.Clear.CGColor, UIColor.Black.CGColor });
                // labelTimePlayed = new UILabel();
                //// labelTimePlayed.Frame = new CGRect(0,10,50,20);
                // labelTimePlayed.Text = "00:00";
                // labelTimePlayed.TextColor = UIColor.White;

                // //seekBar.Frame = new CGRect(50, 10, 100, 20);

                // labelTimeLeft = new UILabel();
                // //labelTimeLeft.Frame = new CGRect(150, 10, 50, 20);
                // labelTimeLeft.Text = "00:00";
                // labelTimeLeft.Text = string.Format("{0:mm\\:ss}", TimeSpan.FromMilliseconds(slider.FileDuration ?? 0));
                // labelTimeLeft.TextColor = UIColor.White;


                // //bootomToolbarView.Frame = new CGRect(0, 10, 200, 20);
                // bootomToolbarView.AddSubview(labelTimePlayed);
                // bootomToolbarView.InsertSubviewAbove(labelTimeLeft, labelTimePlayed);
                // bootomToolbarView.InsertSubviewAbove(seekBar, labelTimeLeft);
                // mainView.InsertSubviewAbove(bootomToolbarView, videoPlayerAV.View);



                //playerLayer = AVPlayerLayer.FromPlayer(player);
                UIApplication.SharedApplication.SetStatusBarHidden(true, true);
            }

            //seekBar.TouchDown += Control_TouchDown;
            //seekBar.TouchUpInside += Control_TouchUpInside;
        }