private void CarouselItemUCStories_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Play") { var value = DataContext as InstaStoryItem; if (value.Play) { CarouVideo.Play(); } else { CarouVideo.Stop(); } } }
private async void CarouselItemUC_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { if (args.NewValue == null) { return; } if (args.NewValue.GetType() == typeof(InstaStoryItem)) { var value = DataContext as InstaStoryItem; value.PropertyChanged += CarouselItemUCStories_PropertyChanged; var DPI = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi; var bounds = Window.Current.Bounds; float scaleHeight = (float)bounds.Height / (float)value.OriginalHeight; float scaleWidth = (float)bounds.Width / (float)value.OriginalWidth; float scale = Math.Min(scaleHeight, scaleWidth); if (value.MediaType == 1) { CarouVideo.Visibility = Visibility.Collapsed; CarouImage.Visibility = Visibility.Visible; CarouImage.Source = new BitmapImage(new Uri(value.ImageList.FirstOrDefault().URI, UriKind.RelativeOrAbsolute)); var ActualWidth = bounds.Width * value.OriginalWidth; var ActualHeight = bounds.Height * value.OriginalHeight; CarouImage.Height = AlignGrid.Height = (int)(value.OriginalHeight * scale); CarouImage.Width = AlignGrid.Width = (int)(value.OriginalWidth * scale); CalcLocationOfMention(); CalcLocationOfHashTags(); CalcLocationOfLocations(); } else { CarouImage.Visibility = Visibility.Collapsed; CarouVideo.Visibility = Visibility.Visible; CarouVideo.PosterSource = new BitmapImage(new Uri(value.ImageList.FirstOrDefault().URI, UriKind.RelativeOrAbsolute)); CarouVideo.Source = new Uri(value.VideoList.FirstOrDefault().Url, UriKind.RelativeOrAbsolute); var ActualWidth = bounds.Width * value.OriginalWidth; var ActualHeight = bounds.Height * value.OriginalHeight; CarouVideo.Height = AlignGrid.Height = (int)(value.OriginalHeight * scale); CarouVideo.Width = AlignGrid.Width = (int)(value.OriginalWidth * scale); CalcLocationOfMention(); CalcLocationOfHashTags(); CalcLocationOfLocations(); } if (value.StoryCTA != null) { SeeMoreGrid.Visibility = Visibility.Visible; if (value.LinkText != null) { AdLinkText.Text = value.LinkText; } } } CarouVideo.Stop(); //var a = await AppCore.InstaApi.StoryProcessor.GetStoryMediaViewers(CarouselItem.Id, PaginationParameters.MaxPagesToLoad(1)); }