コード例 #1
0
        private void DrawMarker(RectangleF rowRect, float position)
        {
            if (Layer.Sublayers != null)
            {
                Layer.Sublayers = new CALayer[0];
            }

            var visibleRect     = Layer.Bounds;
            var currentTimeRect = visibleRect;

            // The red band of the timeMaker will be 7 pixels wide
            currentTimeRect.X     = 0f;
            currentTimeRect.Width = 7f;

            var timeMarkerRedBandLayer = new CAShapeLayer();

            timeMarkerRedBandLayer.Frame    = currentTimeRect;
            timeMarkerRedBandLayer.Position = new PointF(rowRect.X, Bounds.Height / 2f);

            var linePath = CGPath.FromRect(currentTimeRect);

            timeMarkerRedBandLayer.FillColor = UIColor.FromRGBA(1.00f, 0.00f, 0.00f, 0.50f).CGColor;

            timeMarkerRedBandLayer.Path = linePath;

            currentTimeRect.X     = 0f;
            currentTimeRect.Width = 1f;

            CAShapeLayer timeMarkerWhiteLineLayer = new CAShapeLayer();

            timeMarkerWhiteLineLayer.Frame    = currentTimeRect;
            timeMarkerWhiteLineLayer.Position = new PointF(3f, Bounds.Height / 2f);

            CGPath whiteLinePath = CGPath.FromRect(currentTimeRect);

            timeMarkerWhiteLineLayer.FillColor = UIColor.FromRGBA(1.00f, 1.00f, 1.00f, 1.00f).CGColor;
            timeMarkerWhiteLineLayer.Path      = whiteLinePath;

            timeMarkerRedBandLayer.AddSublayer(timeMarkerWhiteLineLayer);
            CABasicAnimation scrubbingAnimation = new CABasicAnimation();

            scrubbingAnimation.KeyPath = "position.x";

            scrubbingAnimation.From = new NSNumber(HorizontalPositionForTime(CMTime.Zero));
            scrubbingAnimation.To   = new NSNumber(HorizontalPositionForTime(duration));
            scrubbingAnimation.RemovedOnCompletion = false;
            scrubbingAnimation.BeginTime           = 0.000000001;
            scrubbingAnimation.Duration            = duration.Seconds;
            scrubbingAnimation.FillMode            = CAFillMode.Both;
            timeMarkerRedBandLayer.AddAnimation(scrubbingAnimation, null);

            Console.WriteLine("Duration in  seconds - " + Player.CurrentItem.Asset.Duration.Seconds);
            var syncLayer = new AVSynchronizedLayer()
            {
                PlayerItem = Player.CurrentItem,
            };

            syncLayer.AddSublayer(timeMarkerRedBandLayer);
            Layer.AddSublayer(syncLayer);
        }
コード例 #2
0
		private void DrawMarker (CGRect rowRect, float position)
		{
			if (Layer.Sublayers != null) {
				Layer.Sublayers = new CALayer[0];
			}

			var visibleRect = Layer.Bounds;
			var currentTimeRect = visibleRect;

			// The red band of the timeMaker will be 7 pixels wide
			currentTimeRect.X = 0f;
			currentTimeRect.Width = 7f;

			var timeMarkerRedBandLayer = new CAShapeLayer ();
			timeMarkerRedBandLayer.Frame = currentTimeRect;
			timeMarkerRedBandLayer.Position = new CGPoint (rowRect.X, Bounds.Height / 2f);

			var linePath = CGPath.FromRect (currentTimeRect);
			timeMarkerRedBandLayer.FillColor = UIColor.FromRGBA (1.00f, 0.00f, 0.00f, 0.50f).CGColor;

			timeMarkerRedBandLayer.Path = linePath;

			currentTimeRect.X = 0f;
			currentTimeRect.Width = 1f;

			CAShapeLayer timeMarkerWhiteLineLayer = new CAShapeLayer ();
			timeMarkerWhiteLineLayer.Frame = currentTimeRect;
			timeMarkerWhiteLineLayer.Position = new CGPoint (3f, Bounds.Height / 2f);

			CGPath whiteLinePath = CGPath.FromRect (currentTimeRect);
			timeMarkerWhiteLineLayer.FillColor = UIColor.FromRGBA (1.00f, 1.00f, 1.00f, 1.00f).CGColor;
			timeMarkerWhiteLineLayer.Path = whiteLinePath;

			timeMarkerRedBandLayer.AddSublayer (timeMarkerWhiteLineLayer);
			CABasicAnimation scrubbingAnimation = new CABasicAnimation ();
			scrubbingAnimation.KeyPath = "position.x";

			scrubbingAnimation.From = new NSNumber (HorizontalPositionForTime (CMTime.Zero));
			scrubbingAnimation.To = new NSNumber (HorizontalPositionForTime (duration));
			scrubbingAnimation.RemovedOnCompletion = false;
			scrubbingAnimation.BeginTime = 0.000000001;
			scrubbingAnimation.Duration = duration.Seconds;
			scrubbingAnimation.FillMode = CAFillMode.Both;
			timeMarkerRedBandLayer.AddAnimation (scrubbingAnimation, null);
			if (Player != null) {
				Console.WriteLine ("Duration in  seconds - " + Player.CurrentItem.Asset.Duration.Seconds);
				var syncLayer = new AVSynchronizedLayer () {
					PlayerItem = Player.CurrentItem,
				};
				syncLayer.AddSublayer (timeMarkerRedBandLayer);
				Layer.AddSublayer (syncLayer);
			}
		}