Giter Club home page Giter Club logo

replaykitunitybridge's Introduction

license

Summary

This is a Unity plugin for iOS that allows you to record the screen and capture gameplay. It includes the Xcode project that it was built in. To start using it, simply drag the PluginSource folder into your Unity project as a sub-folder in the following directory/file path: Assets > Plugins > iOS > ReplayKitUnity > Drag the source and editor folders into here

Blog Post describing the steps to make a bridge: https://medium.com/@SoCohesive/unity-how-to-build-a-bridge-ios-to-unity-with-swift-f23653f6261

Disclaimer:

This plugin is a work in progress and has been built to show the steps of creating a Unity iOS plugin using Swift

Features

  • Record Screen
  • Stop recording of screen
  • Recieve video file (.mp4) of recording
  • Set a restricting time to allow for recording the screen
  • A record button and progress bar of your recording playback that is excluded from the screen recording
  • Share the recorded file via the standard iOS share sheet (mail, twitter, facebook)

Requirements

  • iOS 11.0 or later

Getting Started

  • Go to the "Demo" folder, Main Scene. View the RecordController script for sample code

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

  • Open the Plugin Source folder, Drag the "Source" and "Editor" folder into your Unity project.
  • It must be dragged into the following Unity file path : Assets > Plugins > iOS > ReplayKitUnity

How To Use

  1. Start a screen recording
ReplayKitUnity.StartRecording();
  1. Stop the screen recording
ReplayKitUnity.StopRecording();
  1. Get the video file after recording is complete

a) Subscribe to the onStopCaptureWithFile action in ReplayKitUnity

ReplayKitUnity.Instance.onStopCaptureWithFile += OnStopRecording; (connect to your function)

b) Use the VideoPlayer Unity componnent or any video playback technique to play the .mp4

  1. Get notified when the recording has started
ReplayKitUnity.Instance.onStartRecording += OnStartRecording; (connect to your function)
  1. Set a constrained time to record gameplahy (ie - only 10 seconds)
ReplayKitUnity.AllowedTimeToRecord = 10.0f;
  1. Set the subject line for sharing the video file via email
ReplayKitUnity.MailSubjectText = "Check this recording of my game out!";

Contact:

replaykitunitybridge's People

Contributors

hammadb avatar socohesive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

replaykitunitybridge's Issues

Audio recording fails and repeated surfacing of err=-12731 during recording

I'm encountering an issue with audio recording. The error clause of the handler is called once at the start of recording, with error?.localizedDescription nil. No audio records afterwards, and I get the same log spam over and over:

2019-08-13 11:52:02.316728-0700 test-TESTAPP[1566:1632947] [] [11:52:02.317] CMSampleBufferSetDataBufferFromAudioBufferList signalled err=-12731 (kCMSampleBufferError_RequiredParameterMissing) (bufferList->mBuffers[i].mNumberChannels != expectedNumChannelsPerBuffer || bufferList->mBuffers[i].mDataByteSize == 0 || bufferList->mBuffers[i].mData == NULL) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMediaFramework/EmbeddedCoreMedia-2501.6.1.1/Sources/Core/FigSampleBuffer/FigSampleBuffer.c:4661
0 CoreMedia 0x00000001b195a8e0 CMSampleBufferSetDataBufferFromAudioBufferList + 196 [0x1b192d000 + 186592]
1 ReplayKit 0x00000001d44c9bdc decodeAudioSampleBuffer + 392 [0x1d44c4000 + 23516]
2 ReplayKit 0x00000001d44cfe90 995BB069-5EB0-3A30-9439-D3333EA76348 + 48784 [0x1d44c4000 + 48784]
3 libdispatch.dylib 0x00000001aaf78658 085858AE-2C95-306B-95F1-561CA0CE5E99 + 370264 [0x1aaf1e000 + 370264]
4 libdispatch.dylib 0x00000001aaf791cc 085858AE-2C95-306B-95F1-561CA0CE5E99 + 373196 [0x1aaf1e000 + 373196]
5 libdispatch.dylib 0x00000001aaf567c0 085858AE-2C95-306B-95F1-561CA0CE5E99 + 231360 [0x1aaf1e000 + 231360]
6 libdispatch.dylib 0x00000001aaf571d8 085858AE-2C95-306B-95F1-561CA0CE5E99 + 233944 [0x1aaf1e000 + 233944]
7 libdispatch.dylib 0x00000001aaf604c0 085858AE-2C95-306B-95F1-561CA0CE5E99 + 271552 [0x1aaf1e000 + 271552]
8 libsystem_pthread.dylib 0x00000001aafc8fa8 _pthread_wqthread + 276 [0x1aafbd000 + 49064]
9 libsystem_pthread.dylib 0x00000001aafcbae4 start_wqthread + 8 [0x1aafbd000 + 60132]

My initialization steps for setupAudioInput are unchanged.

Respect Unity Status Bar setting

The status bar is on by default in the new UI window created. Maybe RecordViewController should mirror the unity setting for status bar? Just need to add this
override var prefersStatusBarHidden: Bool { return <value> } to it, and pass the value from unity

Callback for share activity results

It could be useful to expose the results of the share activity to Unity so that a caller can implement their own flow around the results. Can be done with UIActivityViewControllers completionWithItemsHandler.

Buidling Demo App using Xcode 10

The target “Unity-iPhone” contains source code developed with Swift 2.x. This version of Xcode does not support building or migrating Swift 2.x targets.

Asset writer may not be ready for writing

In ReplayKitNative.swift inside the startCapture handler, the safe asset writer may not be ready for writing yet, this occasionally causes the error:
[AVAssetWriterInput appendSampleBuffer:] Cannot append sample buffer: Must start a session

Swift 3?

Any chance the authors can update it to a version of swift that runs in the current XCode?

ReplayKit recording different screen

I am working on an iOS app which used an embedded unity xcode project. The screen record is running from the Unity side and wants to record the Unity camera view. But whenever i call StartRecording it records the iOS app view and not the Unity view. How can i change so that it records my unity view.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.