All Projects → thanh-nguyen-kim → Android_Screen_Recorder_Plugin

thanh-nguyen-kim / Android_Screen_Recorder_Plugin

Licence: GPL-3.0 license
A simple android library project for record android screen in Unity

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Screen Recorder Plugin

UBind
UBind is a value binding component for Unity, which is used to quickly realize the association binding between UI and logical data.
Stars: ✭ 57 (+103.57%)
Mutual labels:  unity3d-plugin
LongScreenshot
This tool makes a number of screenshots, scrolling screen content automatically between each shot
Stars: ✭ 34 (+21.43%)
Mutual labels:  screen-capture
collision-sound
Collision Sound aims to be an easy and powerful way of adding sound to object collisions in Unity
Stars: ✭ 21 (-25%)
Mutual labels:  unity3d-plugin
VRQuestionnaireToolkit
🎓 ---- VRQuestionnaireToolkit ---- 🎓Enables the community to easily collect subjective measures in virtual environments.
Stars: ✭ 86 (+207.14%)
Mutual labels:  unity3d-plugin
meazure
Screen magnification, measurement, capture and color sampling for Windows.
Stars: ✭ 55 (+96.43%)
Mutual labels:  screen-capture
RemoteDesktop
A simple remote desktop server/client application for Windows
Stars: ✭ 30 (+7.14%)
Mutual labels:  screen-capture
Unity.Blog.Override App Delegate
A maintainable way to extend / override app delegate in Unity iOS / OSX standalone player. (Much) more at http://eppz.eu/blog/override-app-delegate-unity-ios-osx-1/
Stars: ✭ 28 (+0%)
Mutual labels:  unity3d-plugin
UnitySoundManager
Sound manager with 3 tracks, language system, pooling system, Fade in/out effects, EventTrigger system and more.
Stars: ✭ 55 (+96.43%)
Mutual labels:  unity3d-plugin
android-capture
Capture video and screenshots from Android devices and emulators.
Stars: ✭ 32 (+14.29%)
Mutual labels:  screen-capture
FPSCounter
FPS counter plugin for BepInEx - measure frame time and plugin performance
Stars: ✭ 27 (-3.57%)
Mutual labels:  unity3d-plugin
Unity-IMGUI-TreeView
Simple Tree View implementation for IMGUI (Editor GUI) in Unity. Includes a special type for working with asset paths, but base data structure and view can be easily extended to support anything.
Stars: ✭ 73 (+160.71%)
Mutual labels:  unity3d-plugin
MultiGame
MultiGame is a tool for rapid development in Unity
Stars: ✭ 16 (-42.86%)
Mutual labels:  unity3d-plugin
UnityProminentColor
Tool to gather main colors of an image using Unity.
Stars: ✭ 40 (+42.86%)
Mutual labels:  unity3d-plugin
karaoke
Karaoke is a neat plugin to parse and display karaoke subtitle files such as SSA/ASS inside Unity
Stars: ✭ 19 (-32.14%)
Mutual labels:  unity3d-plugin
CSharpCompilerSettingsForUnity
Change the C# compiler (csc) used on your Unity project, as you like!
Stars: ✭ 208 (+642.86%)
Mutual labels:  unity3d-plugin
TinyECS
Tiny ECS is an easy to use Entity-Component-System framework that's designed specially for Unity3D.
Stars: ✭ 20 (-28.57%)
Mutual labels:  unity3d-plugin
go-scrap
Go library to capture screen pixels for screenshots or screen recording
Stars: ✭ 68 (+142.86%)
Mutual labels:  screen-capture
awesome-unity
A curated list of awesome Unity games! 🎮
Stars: ✭ 346 (+1135.71%)
Mutual labels:  unity3d-plugin
SimpleKeplerOrbits
Unity3d static 2-body orbits simulation
Stars: ✭ 76 (+171.43%)
Mutual labels:  unity3d-plugin
SafeValues
A simple Unity library for cheating prevention
Stars: ✭ 75 (+167.86%)
Mutual labels:  unity3d-plugin

Android_Utils_Plugin

A simple android library project for Unity which contains some useful features:

  • Capture android screen as a video.
  • Request android permissions at runtime.

Thank for the open source project https://github.com/HBiSoft/HBRecorde which I use as a record service in this repository.

Visit this site to get a details explaining of Unity_Android_Screen_Recorder.

https://killertee.wordpress.com/2018/01/08/unity-android-record-game-screen-with-audio-using-your-ad-hoc-plug-in/

If you are using this library in one of your applications and would like to thank me:

Buy Me A Coffee

or via PayPal:

https://www.paypal.com/paypalme/kampertee

Build guide

  • Clone this project and open it using Android Studio.
  • Make module androidutils.
  • Wait for build process to complete then get your plugin in Android_Screen_Recorder/unityrecorder/build/generated/outputs/aar/unityrecorder-release.aar
  • Copy the unityrecorder-release.aar to Plugins/Android folder inside your project.
  • Add a AndroidManifest.xml in the same folder which have the content below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your package name">
  <application android:icon="@drawable/app_icon" android:launchMode="singleTask" android:label="@string/app_name">
    <activity android:name="com.setik.androidutils.AndroidUtils" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>
</manifest>

Now your plugin is ready to use in any Unity project.

Screen Record guide

To record android screen you have to follow this instruction:

1.Set-up recorder

Call this inside Start() function of your script.

#if UNITY_ANDROID && !UNITY_EDITOR
        using (AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            androidRecorder = unityClass.GetStatic<AndroidJavaObject>("currentActivity");
            androidRecorder.Call("setUpSaveFolder","Tee");//custom your save folder to Movies/Tee, by defaut it will use Movies/AndroidUtils
            int width = (int)(Screen.width > SCREEN_WIDTH ? SCREEN_WIDTH : Screen.width);
            int height = Screen.width > SCREEN_WIDTH ? (int)(Screen.height * SCREEN_WIDTH / Screen.width) : Screen.height;
            int bitrate = (int)(1f * width * height / 100 * 240 * 7);
            int fps = 30;
            bool audioEnable=true;
            androidRecorder.Call("setupVideo", width, height,bitrate, fps, audioEnable, VideoEncoder.H264.ToString());//this line manual sets the video record setting. You can use the defaut setting by comment this code block
        }
#endif

2. Start record

Then call this to start record screen.

#if UNITY_ANDROID && !UNITY_EDITOR
        if (!AndroidUtils.IsPermitted(AndroidPermission.RECORD_AUDIO))//RECORD_AUDIO is declared inside plugin manifest but we need to request it manualy
        {
            AndroidUtils.RequestPermission(AndroidPermission.RECORD_AUDIO);
            onAllowCallback = () =>
            {
                androidRecorder.Call("startRecording");
            };
            onDenyCallback = () => { ShowToast("Need RECORD_AUDIO permission to record voice");};
            onDenyAndNeverAskAgainCallback = () => { ShowToast("Need RECORD_AUDIO permission to record voice");};
        }
        else
            androidRecorder.Call("startRecording");
#endif

3. Stop record

Call

androidRecorder.Call("stopRecording");

4. Handle callback

Create a function name VideoRecorderCallback(string message) inside your project. It will receive callback from java side.
List of messages from java:

  • init_record_error
  • start_record
  • stop_record

Runtime Permissions guide

Runtime permission allow you to request android permission at runtime(for android 6.0 and above). Example: When your game need to access location service, instead of request this permission at the first runtime now you can delay it until the moment your app actually need to use the permission.
Note that. Your app can only request the permissions which have been declared in AndroidManifest.xml

1. You need to declare the permissions in AndroidManifest.xml. Then add this below meta-data to skip request permission dialog when you open app first time

<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

the final AndroidManifest.xml must look similar like this.

<?xml version="1.0" encoding="utf-8"?>
<manifest 
  xmlns:android="http://schemas.android.com/apk/res/android" package="com.setik.androidutils">
  <application android:icon="@drawable/app_icon" android:label="@string/app_name">
    <activity android:name="com.setik.androidutils.AndroidUtils" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
  </application>
</manifest>

2.To check if your app has a permision

public static bool IsPermitted(AndroidPermission permission)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        using (var androidUtils = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            return androidUtils.GetStatic<AndroidJavaObject>("currentActivity").Call<bool>("hasPermission", GetPermissionStrr(permission));
        }
#endif
        return true;
    }

3.To request a permission

public static void RequestPermission(AndroidPermission permission, UnityAction onAllow = null, UnityAction onDeny = null, UnityAction onDenyAndNeverAskAgain = null)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        onAllowCallback = onAllow;
        onDenyCallback = onDeny;
        onDenyAndNeverAskAgainCallback = onDenyAndNeverAskAgain;
        using (var androidUtils = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            androidUtils.GetStatic<AndroidJavaObject>("currentActivity").Call("requestPermission", GetPermissionStrr(permission));
        }
#endif
    }

4. Helper function to convert from enum to android permission string

	private static string GetPermissionStrr(AndroidPermission permission)
    {
        return "android.permission." + permission.ToString();
    }

5. List of android permissions

public enum AndroidPermission
{
    ACCESS_COARSE_LOCATION,
    ACCESS_FINE_LOCATION,
    ADD_VOICEMAIL,
    BODY_SENSORS,
    CALL_PHONE,
    CAMERA,
    GET_ACCOUNTS,
    PROCESS_OUTGOING_CALLS,
    READ_CALENDAR,
    READ_CALL_LOG,
    READ_CONTACTS,
    READ_EXTERNAL_STORAGE,
    READ_PHONE_STATE,
    READ_SMS,
    RECEIVE_MMS,
    RECEIVE_SMS,
    RECEIVE_WAP_PUSH,
    RECORD_AUDIO,
    SEND_SMS,
    USE_SIP,
    WRITE_CALENDAR,
    WRITE_CALL_LOG,
    WRITE_CONTACTS,
    WRITE_EXTERNAL_STORAGE
}

6. Implement 3 functions below to receive callback when you request a permission

private void OnAllow(){}
private void OnDeny(){}
private void OnDenyAndNeverAskAgain(){}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].