Beispiel #1
0
        public async static void RecordVoiceSampleAsync()
        {
            try
            {
                var recorder = new AudioRecorderService();

                recorder.Prepare(AudioRecorderPreset.HighQualitySpeech);

                string directory = SharedStorageService.GetDirectory(Tizen.System.DirectoryType.Sounds);
                string path      = Path.Combine(directory, "Sample.m4a");

                recorder.Start(path);

                // record audio for 30 seconds
                await Task.Delay(30 * 1000);

                recorder.Stop();

                recorder.Dispose();
            }
            catch (InvalidOperationException)
            {
                // TODO: The app is not in an appropriate state for the requested operation, handle exception as appropriate to your scenario.
            }
        }
        public static async Task WriteFileToSharedStorageSampleAsync()
        {
            // Ask the user to grant the privacy permissions at runtime
            var permission = await PrivacyPermissionService.RequestAsync(PrivacyPrivilege.MediaStorage);

            if (permission != PrivacyPermissionStatus.Granted)
            {
                // The permission is not granted
                return;
            }

            if (SharedStorageService.Writable)
            {
                // Store a file in public directory so that other apps can access the file
                var directory = SharedStorageService.GetDirectory(Tizen.System.DirectoryType.Downloads);
                var path      = Path.Combine(directory, "sample.txt");
                File.WriteAllText(path, "Hello World!");
            }
        }