Commit a7584720 authored by JiangWanZhi's avatar JiangWanZhi

去掉了调用麦克风权限的问题

parent 72e7ed7f
......@@ -13,6 +13,8 @@ namespace NatSuite.Examples {
using UnityEditor;
using UnityEngine.UI;
using static UnityEngine.GraphicsBuffer;
using UnityEngine.Rendering.Universal;
using System.IO;
public class ReplayCam : MonoBehaviour
{
......@@ -45,26 +47,25 @@ namespace NatSuite.Examples {
float val = 0;
private IEnumerator Start () {
// Start microphone
microphoneSource = gameObject.AddComponent<AudioSource>();
microphoneSource.mute =
microphoneSource.loop = true;
microphoneSource.bypassEffects =
microphoneSource.bypassListenerEffects = false;
if(recordMicrophone)
microphoneSource.clip = Microphone.Start(null, true, 10, AudioSettings.outputSampleRate);
yield return new WaitUntil(() => Microphone.GetPosition(null) > 0);
microphoneSource.Play();
}
//private IEnumerator Start () {
// // Start microphone
// //microphoneSource = gameObject.AddComponent<AudioSource>();
// //microphoneSource.mute =
// //microphoneSource.loop = true;
// //microphoneSource.bypassEffects =
// //microphoneSource.bypassListenerEffects = false;
// //if(recordMicrophone)
// // microphoneSource.clip = Microphone.Start(null, true, 10, AudioSettings.outputSampleRate);
// //yield return new WaitUntil(() => Microphone.GetPosition(null) > 0);
// //microphoneSource.Play();
//}
private void OnDestroy () {
// Stop microphone
if (recordMicrophone)
{
microphoneSource.Stop();
Microphone.End(null);
//microphoneSource.Stop();
//Microphone.End(null);
}
}
......@@ -103,14 +104,14 @@ namespace NatSuite.Examples {
//audioInput = recordMicrophone ? new AudioInput(recorder, clock, microphoneSource, true) : null;
audioInput = new AudioInput(recorder, clock, audioListener);
// Unmute microphone
microphoneSource.mute = true;// audioInput == null;
//microphoneSource.mute = true;// audioInput == null;
}
public void InterruptRecording() //停止录屏,但是不保存
{
Debug.Log("停止录屏");
// Mute microphone
microphoneSource.mute = true;
//microphoneSource.mute = true;
// Stop recording
audioInput?.Dispose();
cameraInput?.Dispose();
......@@ -122,14 +123,13 @@ namespace NatSuite.Examples {
{
Debug.Log("结束录屏");
// Mute microphone
microphoneSource.mute = true;
//microphoneSource.mute = true;
// Stop recording
audioInput?.Dispose();
cameraInput?.Dispose();
var path = await recorder.FinishWriting();
// Playback recording
Debug.Log($"Saved recording to: {path}");
var prefix = Application.platform == RuntimePlatform.IPhonePlayer ? "file://" : "";
#if UNITY_EDITOR
EditorUtility.OpenWithDefaultApp(path);
......@@ -140,6 +140,51 @@ namespace NatSuite.Examples {
#endif
// 移动端,录频完后,播放录制的视频
//Handheld.PlayFullScreenMovie($"{prefix}{path}");
//OnReplay(path);
}
private void OnReplay(string path)
{
// 预览视频
#if UNITY_EDITOR
EditorUtility.OpenWithDefaultApp(path);
#elif UNITY_IOS
Handheld.PlayFullScreenMovie("file://" + path);
#elif UNITY_ANDROID
Handheld.PlayFullScreenMovie(path);
#endif
string destination = "";
string filename = path.Split('/')[path.Split('/').Length - 1];
if (Application.platform == RuntimePlatform.Android)
{
destination = "/sdcard/DCIM/电子手册";
if (!Directory.Exists(destination))
{
Directory.CreateDirectory(destination);
}
destination = destination + "/" + filename;
Debug.Log(destination);
File.Move(path, destination);
//// 安卓在这里需要去 调用原生的接口去 刷新一下,不然相册显示不出来
//using (AndroidJavaClass playerActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
//{
// using (AndroidJavaObject jo = playerActivity.GetStatic<AndroidJavaObject>("currentActivity"))
// {
// Debug.Log("scanFile:m_androidJavaObject ");
// jo.Call("scanFile", destination);
// }
//}
}
else if (Application.platform == RuntimePlatform.IPhonePlayer)
{
#if UNITY_IOS
IOSAlbumCamera.iosSaveVideoToPhotosAlbum(path);
#endif
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment