private static Image CreateImageFor(TweetMediaViewModel viewModel) => new Image { Source = new BitmapImage(viewModel.Uri), Width = DetermineMediaWidth(viewModel, 200), Height = DetermineMediaHeight(viewModel, 200), Stretch = Stretch.Uniform };
private static double DetermineMediaHeight(TweetMediaViewModel viewModel, double maximumHeight) => viewModel.AspectRatio < 1 ? maximumHeight : double.NaN;
//private static Unosquare.FFME.MediaElement CreateMediaElement() //{ // var mediaElement = new Unosquare.FFME.MediaElement // { // Stretch = Stretch.Uniform, // LoadedBehavior = MediaState.Play, // UnloadedBehavior = MediaState.Close, // Volume = 0 // }; // mediaElement.MediaFailed += (s, e) => // { // Console.WriteLine("Failed to open media: " + e.ErrorException); // }; // mediaElement.MediaOpened += (s, e) => // { // Console.WriteLine("Media opened."); // }; // return mediaElement; //} //private static void UpdateMediaElementFor(Unosquare.FFME.MediaElement mediaElement, TweetMediaViewModel viewModel) //{ // mediaElement.Source = viewModel.Uri; // mediaElement.Width = DetermineMediaWidth(viewModel, 300); // mediaElement.Height = DetermineMediaHeight(viewModel, 300); //} private static double DetermineMediaWidth(TweetMediaViewModel viewModel, double maximumWidth) => viewModel.AspectRatio >= 1 ? maximumWidth : double.NaN;