Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

NatShare - Free Sharing API

Discussion in 'Assets and Asset Store' started by Lanre, Apr 17, 2018.

  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    The receiving app is responsible for parsing the share payload. Given that the video is played back, and is shared properly by iMessage, this means that for some reason Instagram is misreading the video as having a 0 duration. I recommend trying sharing only the video (no text). If this doesn't work, you might have to reach out to Instagram's developer support.
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Do not create a payload without committing it. This will cause a resource leak. Instead, create and commit the payload if your `commit` variable is set to `true`. Can you post the crash logs in a .txt attachment? The logs will contain the reason for the crash.
     
  3. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    Hello,
    I just imported NatShare into my project, but it seems that it's incompatible with Firebase SDK. When I try to build, I get hundreds of errors like this one:
    Code (CSharp):
    1. java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (:androidx.core.core-1.0.0:) and classes.jar (:core-1.0.0-rc02:)
    2.  
    I tired deleting one of the two .aar files but if I delete the Firebase one, it just gets re-imported on build, and if I delete the NatShare one the app builds, but crashes when I try to share the screenshot or save it to camera roll.
    Can you help me please?
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Can you share the logs in a .txt attachment? The logs will contain information on the crash.
     
  5. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    Sure! Assuming you mean the editor logs, here you go

    As regards the logs form the crash that happens when I delete the NatShare .aar, logcat doesn't print anything at all, the only thing that appens is an Android system popup that says "[App name] stopped working". If there are other logs let me know...
     

    Attached Files:

  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    I need the logs from the device that you are experiencing the crash on. That is where any information about the crash will be logged. You can collect logs from an Android device using the logcat SDK tool.
     
  7. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    Sorry, I edited my prevous post while you were replying. I'll double check the logcat logs, maybe they were filtered somehow
     
  8. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    Found, here it is, and here's the code:
    Code (CSharp):
    1.  
    2.         Texture2D texture = new Texture2D(Screen.width, Screen.height);
    3.         JPGRecorder recorder = new JPGRecorder(Screen.width, Screen.height);
    4.  
    5.  
    6.         texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
    7.  
    8.         recorder.CommitFrame(texture.GetPixels32());
    9.  
    10.         string s = await recorder.FinishWriting();
    11.  
    12.         Debug.Log("recorded at: " + s);
    13.        
    14.         SavePayload payload = new SavePayload("IGOODI Images");
    15.         payload.AddMedia(s);
    16.         payload.Commit();
    17.  
    18.         new SharePayload().AddMedia(s).Commit();
     

    Attached Files:

  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    You seem to be trying to use a `JPGRecorder` to take a screenshot. Don't do this. The `JPGRecorder` is for recording image sequences, and as such it returns the path to the directory containing all the images. Unity already has functions for taking screenshots, so use those instead. NatCorder is not a screenshot plugin.
     
    IGOODI_IT likes this.
  10. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    You are right, the problem was that the string contained the path to the directory, not to the screenshot. I had to append "/1.jpg" and now it's working!
    I understand that I'm mis-using the plugin, but using NatCorder with InputCamera is the only way I was able to take a screenshot without including the UI (and it was already in place because I also need to record video). I understand it's possible to get the same result by doing some elaborate tricks with cameras and render textures, but at the moment they're beyond my level.
    For now it seems to be working flawlessly... is there any potential problem I might run into?
    (thank you for your help, by the way)
     
  11. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    You already have a texture that does not contain the UI. All you have to do is call `EncodeToJPG` on the `texture` then write the byte array to a file. The `JPGRecorder` does not handle any rendering setup whatsoever. All it does is write pixel buffers (which you already have with `texture.GetPixels32()`) to an image sequence on the file system. If the file naming convention of the recorder changes, your code will break, so I recommend against using the JPGRecorder.
     
  12. sabanmete57

    sabanmete57

    Joined:
    Mar 20, 2020
    Posts:
    12
    Hi, is it possible to add watermark on my video record using natRecorder ? Thanks.
     
  13. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Hi there. Just a quick note: please post in the NatCorder forum thread for any questions related to NatCorder. You can use a secondary game camera to add a watermark. Add the second camera, then add a UI canvas that can only be seen by this camera (using layer masks). You can add your watermark image in the canvas. Then record your main camera and this second camera with CameraInput.
     
    sabanmete57 likes this.
  14. purplelilgirlmakesgames

    purplelilgirlmakesgames

    Joined:
    Jan 9, 2015
    Posts:
    9
    Hi,

    I'm getting this error in my Unity Cloud Build, I wonder if it's caused by NatShare:

    Code (CSharp):
    1. ;  Undefined symbols for architecture arm64
    2. 34116:> Symbol: _NSGetThumbnail
    3. 34117:> Referenced from: _NatShareBridge_GetThumbnail_m2DFB5D72008596401142857674CE555411C0CFF2 in Assembly-CSharp2.o
    4. 34118: ▸ ❌;  ld: symbol(s) not found for architecture arm64
    5. 34119: ▸ ❌;  clang: error: linker command failed with exit code 1 (use -v to see invocation)
    I am using the latest version from the AssetStore.

    Thanks.
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Delete NatShare in your project, reimport it from the Asset Store, then recreate your UCB build (clear any build caches).
     
  16. GilbertLau

    GilbertLau

    Joined:
    Dec 3, 2017
    Posts:
    26
    I got the following duplicate class error when I build my project to android 7.1 and IL2CPP with .net 2.0. If I delete the core-1.0.0-rc02 from NatSuite/plugin/android, my project would compile but then crash when launch with error saying androidx library not found. Would you please help? I am using both NatDevice and Natcorder, so would like to have this as well. Thanks.
    1. java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar :)androidx.core.core-1.0.0:) and classes.jar :)core-1.0.0-rc02:)
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Can you try deleting the other library (the one not packaged with NatShare) to see if that works?
     
  18. ericford

    ericford

    Joined:
    Jul 28, 2017
    Posts:
    5
    Hi there, looking for some help with an issue I am getting when I try to simply share some text. I am using this code that triggers on a button press:

    Code (CSharp):
    1. var payload = new SharePayload().AddText("testing");
    2.         payload.Commit();
    When called, my Android phone shows a native "Choose an action. No apps can perform this action". (image attached).

    Any ideas why? I have other places in the same app where I share video and it works as expected (giving a list of apps I can share the video to).

    Thanks
     

    Attached Files:

  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    It would seem that you don't have any apps that receives plain text and nothing else.
     
  20. ericford

    ericford

    Joined:
    Jul 28, 2017
    Posts:
    5
    Sorry, that's not the problem. I ended up using EasyMobile asset and their solution for sharing works flawlessly. I tried sharing the exact same message I tried with your plugin and it was able to share the message just fine. Share prompt shows a lot of apps on my phone that can receive plain text lol
     
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Ah this is good to know. I'll check it out when I can, thanks.
     
  22. Kaleval

    Kaleval

    Joined:
    Apr 19, 2016
    Posts:
    7
    Hi,
    I'm using the latest and gratest version of NatShare, and I'm getting an unsatisfied constraint error on iOS 14.0.1.
    When share() function is called, iOS has this nice looking zoom-out effect with black border around the app, then the share screen appears, and right after sharing the app freezes.


    2020-10-26 11:04:13.707052+0200 qa[1822:504297] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want.
    Try this:
    (1) look at each constraint and try to figure out which you don't expect;
    (2) find the code that added the unwanted constraint or constraints and fix it.
    (
    "<NSLayoutConstraint:0x281443ca0 _UIActivityActionCellTitleLabel:0x125bb9180.height >= 22 (active)>",
    "<NSLayoutConstraint:0x2814437f0 V:|-(15)-[_UIActivityActionCellTitleLabel:0x125bb9180] (active, names: '|':UIView:0x12b5db390 )>",
    "<NSLayoutConstraint:0x281443840 V:[_UIActivityActionCellTitleLabel:0x125bb9180]-(15)-| (active, names: '|':UIView:0x12b5db390 )>",
    "<NSLayoutConstraint:0x281455ea0 'UIView-Encapsulated-Layout-Height' UIView:0x12b5db390.height == 50.3333 (active)>"
    )

    Opened an issue in github
    https://github.com/natsuite/NatShare-API/issues/101#issue-729398829
     
  23. Lando9000

    Lando9000

    Joined:
    Apr 14, 2013
    Posts:
    36
    I’m using NatCorder, NatDevice and Natshare. Everything works great from sharing to screen recordings/previews apart from the SavePayload, crashes on IOS and Android when trying to save video or image. Is this a known bug?

    I have made a clean project which only consists of Natcorder and NatShare, i simply add a simple save payload at the bottom of stop recording inside the ReplayCam example script and scene, consistantly crashes on my two test devices iPhone 11 Pro iOS 14 and Samsung S8 Android 9
    - Unity 2020.1.5f1
    - latest version of the plugins

    Example code. Note showing a preview of the video works but crashes on save.


    Code (CSharp):
    1.  
    2. public async void StopRecording () {
    3.             // Mute microphone
    4.             microphoneSource.mute = true;
    5.             // Stop recording
    6.             audioInput?.Dispose();
    7.             cameraInput.Dispose();
    8.             var path = await recorder.FinishWriting();
    9.             // Playback recording
    10.             Debug.Log($"Saved recording to: {path}");
    11.             //Handheld.PlayFullScreenMovie($"file://{path}");
    12.  
    13.             bool success = await new SavePayload().AddMedia(path).Commit();
    14.         }
     
    Last edited: Oct 28, 2020
  24. Kaleval

    Kaleval

    Joined:
    Apr 19, 2016
    Posts:
    7
    The code looks mkay,
    Do you have any errors popping up in the debug console?
    Does the app has storage permission? o_O
     
    Lanre likes this.
  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Thanks for bringing this to my attention. I'll check it out.
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    In the case of a crash always share the logs, along with the stack trace if available. That will contain the exact reason for any crash. This sounds like a permissions issue.
     
  27. mtalbott

    mtalbott

    Joined:
    Dec 21, 2011
    Posts:
    125
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    mtalbott likes this.
  29. mtalbott

    mtalbott

    Joined:
    Dec 21, 2011
    Posts:
    125
    have you had a chance to take a look?
     
  30. Yuri1976

    Yuri1976

    Joined:
    Mar 23, 2016
    Posts:
    7
    Hello everyone. I have just bought NatCorder

    So far everything seems pretty straightforward. I can capture and save the video on the device (using NatShare) and can tweak the screen resolution and other parameters pretty easily.

    However, I have a couple of probably stupid questions.

    -> Microphone doesn't seem to be working. I am only testing on Android for now but I am wondering if I have to request permission and access before.
    -> ReplayCam Scene. the Preview panel hide while playing. When I try to do it in another scene It stays in front of the camera...is there anything I am missing?
    -> UI. Any way to hide the UI elements? I am using an ARCamera and I have tried to use another camera for UI but it doesn't seem to be working.

    Any help?

    Cheers
    Yuri
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Yup check out my comments on the issues.
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Hey there, for NatCorder issues please post on the NatCorder forum thread.
    The app should request camera and microphone permissions the very first time you open it. If not, enable it in your device settings. And make sure that "record microphone" is enabled (I presume you are running the ReplayCam example).
    I'm not sure what you're describing here. What about another scene? I don't recommend using ReplayCam in/with another scene. The ReplayCam example is made for illustration purposes only. It doesn't support anything beyond what is given.
    You can use layer masks so that you have one camera that sees the 3D objects and another that sees only the UI (this step is Unity-specific and has nothing to do with NatCorder). You can then record the former camera with a CameraInput.
     
  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    NatShare 1.2.5 is ready with the iOS crash when the user cancels. I've moved NatShare to use the Unity Package Manager system. It's a lot cleaner, so check out the main README on how to import NatShare now.
     
    timbokoppers likes this.
  34. FITT3DINC

    FITT3DINC

    Joined:
    Nov 19, 2020
    Posts:
    1
    Hello,

    I'm having trouble getting the sharing the NatCorder to work with Natshare API for iOS. Here are screenshots and I can't figure out solutions.

    If anyone could please help me that would mean a lot, thank you so much!
     

    Attached Files:

  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,610
    Hey I just replied to your email. You need to import NatShare's namespace, `NatSuite.Sharing`.
     
unityunity