示例#1
0
        ImageSource IVideoUtils.GetVideoThumbnail(string url)
        {
            NSUrl videoUrl = NSUrl.CreateFileUrl(url, null);

            var asset          = AVAsset.FromUrl(videoUrl);
            var imageGenerator = AVAssetImageGenerator.FromAsset(asset);

            imageGenerator.AppliesPreferredTrackTransform = true;
            var seconds = asset.Duration.Seconds;

            CoreMedia.CMTime actualTime;
            CoreMedia.CMTime cmTime = asset.Duration;
            var timeScale           = asset.Duration.TimeScale;

            cmTime.Value = (seconds > 5) ? timeScale * 5 : timeScale * 1;
            NSError error;
            var     imageRef = imageGenerator.CopyCGImageAtTime(cmTime, out actualTime, out error);

            if (imageRef == null)
            {
                return(null);
            }

            var uiImage = UIImage.FromImage(imageRef);



            var img = Xamarin.Forms.ImageSource.FromStream(() => ((uiImage.AsPNG().AsStream())));


            return(img);
        }
示例#2
0
 public extern static bool bool_objc_msgSendSuper_CMTime_CMTime_CMTime(IntPtr receiver, IntPtr selector, CoreMedia.CMTime arg1, CoreMedia.CMTime arg2, CoreMedia.CMTime arg3);
示例#3
0
 public extern static bool bool_objc_msgSendSuper_CMTime_float_float_CMTimeRange(IntPtr receiver, IntPtr selector, CoreMedia.CMTime arg1, float arg2, float arg3, CoreMedia.CMTimeRange arg4);
示例#4
0
 public extern static bool bool_objc_msgSendSuper_CMTime_CGAffineTransform_CGAffineTransform_CMTimeRange(IntPtr receiver, IntPtr selector, CoreMedia.CMTime arg1, CoreGraphics.CGAffineTransform arg2, CoreGraphics.CGAffineTransform arg3, CoreMedia.CMTimeRange arg4);