Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C# by Natcorder ( 8 years ago )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using NatCorderU.Core;
using NatCorderU.Core.Recorders;
//using NatCorderU.Core.Timing;
using NatCorderU.Core.Clocks;
using NatMicU.Core;
using NatMicU.Core.Recorders;
//using NatCamU.Core;
using NatShareU;
using System.Configuration;




public class NatMicCorder : MonoBehaviour {

 #region --Op vars--
 public bool shareRecordings;
 public Camera recordingCamera;
 public GameObject shareScreen;
 Container container;

 //public RawImage previewRawImage;
 //public AspectRatioFitter previewAspectFitter;
 private    CameraRecorder cameraRecorder;
 private RealtimeClock recordingClock;
 int width = 1280;

 int height = 720;
 int framerate = 30;
 //int bitrate = (int)(960 * 540 * 11.4f);
 //int keyframeInterval = 3;






 #endregion

 #region --Operations--


 #endregion

 #region --Recording--

 public void StartRecording () {

  //Configuration myConfig = new Configuration(Screen.width/2, Screen.height/2);
 //VideoFormat myvideoformat = new VideoFormat(Screen.width/2,Screen.height/2,framerate,bitrate,keyframeInterval);
  //VideoFormat myVideo  = new VideoFormat(Screen.width/4,Screen.height/4,framerate,bitrate,keyframeInterval);
  var VideoFormat  = new VideoFormat(Screen.width/6,Screen.height/6,framerate);
  // Start the microphone
  var microphoneFormat = Format.Default;
  NatMic.StartRecording(microphoneFormat, OnSampleBuffer);
  // Start recording
  recordingClock = new RealtimeClock();
  var audioFormat = new AudioFormat(microphoneFormat.sampleRate, microphoneFormat.channelCount);

  NatCorder.StartRecording(Container.MP4, VideoFormat.Screen, audioFormat, OnRecording);

  // Create a camera recorder for the main cam
  //cameraRecorder = CameraRecorder.Create(recordingCamera, recordingClock);
  cameraRecorder = CameraRecorder.Create(recordingCamera,VideoFormat.Screen,recordingClock);
 }


 // to stop the recording
 public void StopRecording () {
  // Stop the microphone
  NatMic.StopRecording();
 // Microphone.End(null);
  // Stop recording
  cameraRecorder.Dispose();
  NatCorder.StopRecording();

  shareScreen.SetActive (true);

 }
 #endregion

 #region --Callbacks--

 // Invoked by NatCam once the camera preview starts
 private void OnPreviewStart () {
  // Display the camera preview
  //previewRawImage.texture = NatCam.Preview;
  // Scale the panel to match aspect ratios
       // previewAspectFitter.aspectRatio = NatCam.Preview.width / (float)NatCam.Preview.height;
 }

 // Invoked by NatMic on new microphone events
 private void OnSampleBuffer (AudioEvent audioEvent, float[] sampleBuffer, long timestamp, Format format) {
  // Send sample buffers directly to NatCorder for recording
  if (audioEvent == AudioEvent.OnSampleBuffer && NatCorder.IsRecording)
   NatCorder.CommitSamples(sampleBuffer, recordingClock.CurrentTimestamp);
 }

 string videoPath ;
 // Invoked by NatCorder once video recording is complete
 //public void OnRecording (string path) {
 public void OnRecording(string path)

 { 

  videoPath = path;

   Debug.Log("OnRecording=============" + path);
     
  Debug.Log("OnRecordingelsePart=============" + path);
//   #if UNITY_EDITOR
//   UnityEditor.EditorUtility.OpenWithDefaultApp(path);
//   #elif UNITY_IOS
   Debug.Log("OnRecordingIOS=============" + path);
  Handheld.PlayFullScreenMovie("file://" + path , Color.black , FullScreenMovieControlMode.Minimal , FullScreenMovieScalingMode.AspectFill);
//   #elif UNITY_ANDROID
//  Handheld.PlayFullScreenMovie("file://" + path,Color.black,FullScreenMovieControlMode.Minimal,FullScreenMovieScalingMode.AspectFill);
//   #endif

    
 }


 // For sharing the videopath.
  public void ShareVideo()
 {
  NatShare.ShareMedia (videoPath);
 }



 

}


 #endregion

 

Revise this Paste

Your Name: Code Language: