private void HandleVideo(string tempPath) { if (tempPath == null || tempPath == "") { output.text = "Recording failed"; StartCoroutine(ResetText()); return; } string filename = vidTime.ToString("yyyyMMdd_HHmmss") + Path.GetExtension(tempPath); output.text = "Video Recorded: " + filename; NativeGallery.SaveVideoToGallery(tempPath, "augKlimb", filename); string newPath = Path.Combine(Path.GetDirectoryName(tempPath), filename); File.Move(tempPath, newPath); Debug.Log(newPath); shareButton.SetActive(true); shareButton.GetComponent <Button>().onClick.AddListener(delegate { new NativeShare().AddFile(newPath).Share(); }); }
private void OnFileReady(string fileSrc) { string fileDst = DateTime.Now.ToString("ddMMyyyy_HHmmssfff") + "{0}.mp4"; var result = NativeGallery.SaveVideoToGallery(fileSrc, Application.productName, fileDst, errMsg => logger += errMsg); logger += "Video saving permission: " + result; }
//Last callback - do whatever you need next public void OnFinish() { defaultHandler.OnFinish(); //NativeGallery.Permission permission = NativeGallery.SaveVideoToGallery(pathNewVideoToPlay, "TrimmedVideo", "newVideo_Trimmed.mp4"); NativeGallery.SaveVideoToGallery(pathNewVideoToPlay, "TrimmedVideo", "newTrimmedVideo.mp4"); Handheld.Vibrate(); //Handheld.PlayFullScreenMovie("file://" + pathNewVideoToPlay, Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFit); Application.OpenURL("https://www.instagram.com/?hl=it"); }
public void SaveVideo(string videoPath, VideoFormat videoFormat) { string videoName = GenerateMediaName(videosBaseName, GetVideoFormatName(videoFormat)); if (!Application.isEditor) { NativeGallery.SaveVideoToGallery(videoPath, mediaPath, videoName); } else { SaveVideoForEditor(videoPath, videoName); } }
public void Close() { _writer.release(); #if !UNITY_EDITOR && UNITY_ANDROID if (!File.Exists(_filePath)) { return; } try { NativeGallery.SaveVideoToGallery(_filePath, "InvisibleCamera", _fileName); File.Delete(_filePath); } catch (Exception e) { a = e.Message; } #endif }
/// <summary> /// 保存视频到相册 : 从byte[] /// </summary> public static void SaveVideo(byte[] data, Action <bool> callBack = null) { try { NativeGallery.Permission permission = NativeGallery.SaveVideoToGallery(data, Application.productName, DateTime.Now.ToFileTime() + ".jpg", (string info) => { if (info == null) { ShowToast("保存视频成功 ! "); } else { ShowToast("保存视频失败 : " + info); } if (callBack != null) { callBack(info == null); } }); if (permission != NativeGallery.Permission.Granted) { ShowToast("保存视频失败 : 没有权限"); //打开应用程序设置 if (NativeGallery.CanOpenSettings()) { NativeGallery.OpenSettings(); } if (callBack != null) { callBack(false); } } } catch (Exception ex) { ShowToast("保存视频失败 : " + ex.Message); if (callBack != null) { callBack(false); } } }