public static bool TryGenerateVideoThumbnail2(string localFile, CGSize size, out UIImage image, string extensionHint = ".mov") { image = null; try { const int secondToGet = 1; const int timeScale = 60; var asset = AVAsset.FromUrl(NSUrl.FromFilename(localFile)); var generator = new AVAssetImageGenerator(asset); var time = new CMTime(secondToGet, timeScale); CMTime actualTime; NSError error; var cgImage = generator.CopyCGImageAtTime(time, out actualTime, out error); if (error == null) { image = new UIImage(cgImage); image = UIImageExtensions.ResizeAndDispose(image, size, ResizeMethod.AspectFill, ResizeAlignment.CenterCenter ); return(true); } } catch { } return(false); }
public static bool TryGenerateVideoThumbnail(string localFile, CGSize size, out UIImage image) { image = null; try { const float secondToGet = 1.0f; using (var player = new MPMoviePlayerController(NSUrl.FromFilename(localFile))) { image = player.ThumbnailImageAt( secondToGet, MPMovieTimeOption.NearestKeyFrame ); image = UIImageExtensions.ResizeAndDispose(image, size, ResizeMethod.AspectFill, ResizeAlignment.CenterCenter ); player.Stop(); } } catch { return(false); } return(true); }
private void UpdateVideoAsset(PHAsset asset) { _gradientView.Hidden = false; _gradientView.Image = UIImageExtensions.FromBundle(BundleAssets.Gradient) .CreateResizableImage(UIEdgeInsets.Zero, UIImageResizingMode.Stretch); _iconView.Hidden = false; _durationLabel.Hidden = false; _iconView.Image = UIImageExtensions.FromBundle(BundleAssets.IconBadgeVideo); _durationLabel.Text = _durationFormatter.StringFromTimeInterval(asset.Duration); }
private void UpdateImageAsset(PHAsset asset) { if (asset.MediaSubtypes == PHAssetMediaSubtype.PhotoLive) { _gradientView.Hidden = false; _gradientView.Image = UIImageExtensions.FromBundle(BundleAssets.Gradient); _iconView.Hidden = false; _durationLabel.Hidden = true; _iconView.Image = UIImageExtensions.FromBundle(BundleAssets.IconBadgeLivePhoto); } else { _gradientView.Hidden = true; _iconView.Hidden = true; _durationLabel.Hidden = true; } }
public void Update(int index, LayoutConfiguration layoutConfiguration) { var layoutModel = new LayoutModel(layoutConfiguration, 0); var actionCount = layoutModel.NumberOfItems(layoutConfiguration.SectionIndexForActions); TitleLabel.TextColor = UIColor.Black; if (index == 0) { TitleLabel.Text = layoutConfiguration.FirstNameOfActionItem; ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonCamera); } else if (index == 1) { TitleLabel.Text = layoutConfiguration.SecondNameOfActionItem; ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonPhotoLibrary); } var isFirst = index == 0; var isLast = index == actionCount - 1; switch (layoutConfiguration.ScrollDirection) { case UICollectionViewScrollDirection.Horizontal: TopOffset.Constant = isFirst ? 10 : 5; BottomOffset.Constant = isLast ? 10 : 5; LeadingOffset.Constant = 5; TrailingOffset.Constant = 5; break; case UICollectionViewScrollDirection.Vertical: TopOffset.Constant = 5; BottomOffset.Constant = 5; LeadingOffset.Constant = isFirst ? 10 : 5; TrailingOffset.Constant = isLast ? 10 : 5; break; default: throw new ArgumentOutOfRangeException(); } }
public override void WillDisplayActionItem(ImagePickerController controller, UICollectionViewCell cell, int index) { if (cell is IconWithTextCell iconWithTextCell) { iconWithTextCell.TitleLabel.TextColor = UIColor.Black; switch (index) { case 0: iconWithTextCell.TitleLabel.Text = "Camera"; iconWithTextCell.ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonCamera); break; case 1: iconWithTextCell.TitleLabel.Text = "Photos"; iconWithTextCell.ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonPhotoLibrary); break; } } }