Ejemplo n.º 1
0
        private static void Save_Data(queue Finsh_queue)
        {
            DataSql      _DataSql = new DataSql();
            UIImage      image;
            LibraryWords library = new LibraryWords();



            var myByteArray = File.ReadAllBytes(Finsh_queue.Filename);

            byte[] myByteThumbnail = null;


            if (Finsh_queue._Type == "Video")
            {
                //   byte[] myByteArray;
                CoreMedia.CMTime actualTime;
                NSError          outError;
                using (var asset = AVAsset.FromUrl(NSUrl.FromFilename(Finsh_queue.Filename)))
                    using (var imageGen = new AVAssetImageGenerator(asset))
                        using (var imageRef = imageGen.CopyCGImageAtTime(new CoreMedia.CMTime(1, 1), out actualTime, out outError))
                        {
                            if (imageRef == null)
                            {
                                // return null;
                            }
                            image = UIImage.FromImage(imageRef);
                        }
                using (NSData imageData = image.AsPNG())
                {
                    myByteThumbnail = new Byte[imageData.Length];
                    System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteThumbnail, 0, Convert.ToInt32(imageData.Length));
                }


                if (save.Savegerlly)
                {
                    if (File.Exists(Finsh_queue.Filename))
                    {
                        savedowloaning file = new savedowloaning();
                        // AMvideo.SaveToAlbum(Finsh_queue.Filename);
                        file.Get_clipfile(Finsh_queue.ID.ToString(), myByteArray);
                        // ALAssetsLibrary lib = new ALAssetsLibrary();
                        // lib.WriteVideoToSavedPhotosAlbum(NSUrl.FromFilename(Finsh_queue.Filename), (t, u) => { });
                    }
                }
            }
            else
            {
                myByteThumbnail = myByteArray;


                if (save.Savegerlly)
                {
                    savedowloaning file = new savedowloaning();
                    file.Get_imagefile(Finsh_queue.ID.ToString(), myByteArray);
                }
            }


            _DataSql.process(library.File(2), library.INSERT(2), DataSql_Parameters(Path.GetFileName(Finsh_queue.Filename), myByteArray, myByteThumbnail, Finsh_queue._Type));
        }