Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    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

Project Tiny and utilizing device camera and microphone

Discussion in 'Project Tiny' started by ovirta, Mar 10, 2020.

  1. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    40
    As subject states we would be interested in creating browser apps for which Project Tiny would be a perfect choice. We also want to utilize device camera and microphone.

    Is this possible with Project Tiny?
    Any samples already doing this available?

    Thanks!
     
  2. yossi_horowitz_artie

    yossi_horowitz_artie

    Joined:
    Jan 30, 2019
    Posts:
    87
    We've made various modifications to Tiny's included JavaScript and C++ code to make microphone access possible. It was not a straightforward process. :)
     
  3. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    40
    I can imagine :)

    There is some discussion on sharing data between js and c# here and here. These are for WebGL but procedure should be the same.
    - js side methods exported to LibraryManager mergeInto(LibraryManager.library).
    - c# class imports js side methods via [DllImport("__Internal")]

    Sharing microphone data is then possible via shared array:
    [DllImport("__Internal")]
    private static extern void InitJavaScriptSharedArray(float[] array, int length);

    Js side writes data to the array, which is then read on c# side.

    Just wondering if the same approach would work with device camera, where data would be shared from js to c# and written to eg rawimage or rawtexture?
     
  4. yossi_horowitz_artie

    yossi_horowitz_artie

    Joined:
    Jan 30, 2019
    Posts:
    87
    I don't see why it wouldn't! We'll find out at my company in a few months.
     
  5. ovirta

    ovirta

    Joined:
    Mar 20, 2015
    Posts:
    40
    I agree. MediaRecorder ondataavailable should make it straighforward to access video data on browser side and to send it to tiny side using blob object.
     
unityunity