|
1 |
| -using NatCorder; |
2 |
| -using NatCorder.Clocks; |
3 |
| -using NatCorder.Inputs; |
4 |
| -using NatShare; |
| 1 | +using NatSuite.Recorders; |
| 2 | +using NatSuite.Recorders.Clocks; |
| 3 | +using NatSuite.Recorders.Inputs; |
| 4 | +using NatSuite.Sharing; |
5 | 5 | using OpenCVForUnity.CoreModule;
|
6 | 6 | using OpenCVForUnity.ImgprocModule;
|
7 | 7 | using OpenCVForUnity.UnityUtils;
|
@@ -833,43 +833,79 @@ public void OnPlayVideoFullScreenButtonClick()
|
833 | 833 | /// <summary>
|
834 | 834 | /// Raises the share button click event.
|
835 | 835 | /// </summary>
|
836 |
| - public void OnShareButtonClick() |
| 836 | + public async void OnShareButtonClick() |
837 | 837 | {
|
838 | 838 | Debug.Log("OnShareButtonClick ()");
|
839 | 839 |
|
840 | 840 | if (isVideoPlaying || isVideoRecording || isFinishWriting || string.IsNullOrEmpty(videoPath))
|
841 | 841 | return;
|
842 | 842 |
|
843 |
| - using (var payload = new SharePayload("NatCorderWithOpenCVForUnityExample", |
844 |
| - completionHandler: () => |
845 |
| - { |
846 |
| - Debug.Log("User shared video!"); |
847 |
| - } |
848 |
| - )) |
| 843 | + var mes = ""; |
| 844 | + |
| 845 | +#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR |
| 846 | + try |
| 847 | + { |
| 848 | + var success = await new SharePayload() |
| 849 | + .AddText("User shared video! [NatCorderWithOpenCVForUnity Example](" + NatCorderWithOpenCVForUnityExample.GetNatCorderVersion() + ")") |
| 850 | + .AddMedia(videoPath) |
| 851 | + .Commit(); |
| 852 | + |
| 853 | + mes = $"Successfully shared items: {success}"; |
| 854 | + } |
| 855 | + catch (ApplicationException e) |
| 856 | + { |
| 857 | + mes = e.Message; |
| 858 | + } |
| 859 | +#else |
| 860 | + mes = "NatShare Error: SharePayload is not supported on this platform"; |
| 861 | +#endif |
| 862 | + |
| 863 | + Debug.Log(mes); |
| 864 | + |
| 865 | + if (fpsMonitor != null) |
849 | 866 | {
|
850 |
| - payload.AddText("User shared video!"); |
851 |
| - payload.AddMedia(videoPath); |
| 867 | + fpsMonitor.consoleText = mes; |
| 868 | + await Task.Delay(2000); |
| 869 | + fpsMonitor.consoleText = ""; |
852 | 870 | }
|
853 | 871 | }
|
854 | 872 |
|
855 | 873 | /// <summary>
|
856 | 874 | /// Raises the save to camera roll button click event.
|
857 | 875 | /// </summary>
|
858 |
| - public void OnSaveToCameraRollButtonClick() |
| 876 | + public async void OnSaveToCameraRollButtonClick() |
859 | 877 | {
|
860 | 878 | Debug.Log("OnSaveToCameraRollButtonClick ()");
|
861 | 879 |
|
862 | 880 | if (isVideoPlaying || isVideoRecording || isFinishWriting || string.IsNullOrEmpty(videoPath))
|
863 | 881 | return;
|
864 | 882 |
|
865 |
| - using (var payload = new SavePayload("NatCorderWithOpenCVForUnityExample", |
866 |
| - completionHandler: () => |
867 |
| - { |
868 |
| - Debug.Log("User saved video to camera roll!"); |
869 |
| - } |
870 |
| - )) |
| 883 | + var mes = ""; |
| 884 | + |
| 885 | +#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR |
| 886 | + try |
| 887 | + { |
| 888 | + var success = await new SavePayload("NatCorderWithOpenCVForUnityExample") |
| 889 | + .AddMedia(videoPath) |
| 890 | + .Commit(); |
| 891 | + |
| 892 | + mes = $"Successfully saved items: {success}"; |
| 893 | + } |
| 894 | + catch (ApplicationException e) |
| 895 | + { |
| 896 | + mes = e.Message; |
| 897 | + } |
| 898 | +#else |
| 899 | + mes = "NatShare Error: SavePayload is not supported on this platform"; |
| 900 | +#endif |
| 901 | + |
| 902 | + Debug.Log(mes); |
| 903 | + |
| 904 | + if (fpsMonitor != null) |
871 | 905 | {
|
872 |
| - payload.AddMedia(videoPath); |
| 906 | + fpsMonitor.consoleText = mes; |
| 907 | + await Task.Delay(2000); |
| 908 | + fpsMonitor.consoleText = ""; |
873 | 909 | }
|
874 | 910 | }
|
875 | 911 |
|
|
0 commit comments