private async void OnCardChromeHolding(object sender, HoldingRoutedEventArgs e) { if (e.PointerDeviceType == PointerDeviceType.Touch && e.HoldingState == HoldingState.Started) { // To create a continuous video playing experience, let's pause it here. _mediaElement.Pause(); // Record the location as we want to resume from here on another device. _mediaPlayedPosition = _mediaElement.Position; // We don't want to visually move the video player. Instead, we want to create the illusion that // a "copy" of it is being dragged down to another device. So here we use RenderTargetBitmap to // create such visual. var bitmap = new RenderTargetBitmap(); await bitmap.RenderAsync(Card); MediaCopy.Source = bitmap; MediaContainer.IsHitTestVisible = false; // Create animations to show that a "copy" of the video player is popped up and ready to be dragged up. Card.Fade(0.3f).Start(); MediaCopy .Fade(0.7f, 1) .Then() .Scale(0.975f, 0.975f, (float)Card.ActualWidth / 2, (float)Card.ActualHeight / 2, 300d) .Then() .Offset(offsetY: -24.0f, duration: 400d) .Start(); // Create an animation that changes the offset of the "copy" based on the manipulation progress. _mediaCopyVisual = VisualExtensions.GetVisual(MediaCopy); var progressExpressionNode = _progress.GetReference().GetScalarProperty("Progress"); _mediaCopyVisual.StartAnimation("Offset.Y", progressExpressionNode * -_maxDistance); try { // Let InteractionTracker to handle the swipe gesture. _interactionSource.TryRedirectForManipulation(_pressedPoint); // Send the card json and media played position over using Remote Sessions API. await RomeShare.SendMediaDataAsync(_cardJson, _mediaPlayedPosition, MediaUrl); } catch (UnauthorizedAccessException) { } } }
private async Task ResetMediaCopyAsync() { CardsHost.IsHitTestVisible = false; // Reset the opacity, scale and position of the "copy" and fade in the real video player. await MediaCopy .Offset(offsetY : 0.0f, duration : 300d) .Scale(1.0f, 1.0f, (float)Card.ActualWidth / 2, (float)Card.ActualHeight / 2, 300d) .StartAsync(); MediaCopy.Fade(0.0f, 400d).Start(); await Card.Fade(1.0f, 400d).StartAsync(); // Reset the InteractionTracker's position. _tracker.TryUpdatePosition(Vector3.Zero); CardsHost.IsHitTestVisible = true; MediaContainer.IsHitTestVisible = true; }