From e9c07eac9c40a3743a42c6a2b66c3cbbca744f95 Mon Sep 17 00:00:00 2001
From: Santiago Lo Coco <se23m504@technikum-wien.at>
Date: Tue, 19 Nov 2024 00:27:37 +0100
Subject: [PATCH] Save recording to the Videos folder

---
 Assets/Scripts/VideoCaptureHandler.cs | 9 +++++++++
 ProjectSettings/ProjectSettings.asset | 1 +
 2 files changed, 10 insertions(+)

diff --git a/Assets/Scripts/VideoCaptureHandler.cs b/Assets/Scripts/VideoCaptureHandler.cs
index 4339770..e6adf31 100644
--- a/Assets/Scripts/VideoCaptureHandler.cs
+++ b/Assets/Scripts/VideoCaptureHandler.cs
@@ -142,7 +142,11 @@ namespace WebViewStream
             }
         }
 
+#if WINDOWS_UWP && !UNITY_EDITOR
+        private async void OnStartedVideoCaptureMode(VideoCapture.VideoCaptureResult result)
+#else
         private void OnStartedVideoCaptureMode(VideoCapture.VideoCaptureResult result)
+#endif
         {
             if (result.success)
             {
@@ -150,7 +154,12 @@ namespace WebViewStream
                     "WebView_{0}.mp4",
                     DateTime.UtcNow.ToString("yyyy-MM-ddTHHmmssZ")
                 );
+#if WINDOWS_UWP && !UNITY_EDITOR
+                StorageLibrary videosLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Videos);
+                string filepath = Path.Combine(videosLibrary.SaveFolder.Path, filename);
+#else
                 string filepath = Path.Combine(Application.persistentDataPath, filename);
+#endif
                 Debug.Log("Saving video to: " + filepath);
 
                 videoCapture.StartRecordingAsync(filepath, OnStartedRecordingVideo);
diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset
index 9edf22e..53d7bb0 100644
--- a/ProjectSettings/ProjectSettings.asset
+++ b/ProjectSettings/ProjectSettings.asset
@@ -676,6 +676,7 @@ PlayerSettings:
   syncCapabilities: 1
   platformCapabilities:
     WindowsStoreApps:
+      VideosLibrary: True
       GazeInput: True
       SpatialPerception: True
       InternetClient: True