Sound capture. MacOS permissions. Java Audio API
Asked Answered
P

1

8

I'm trying to capture sound from microphone via Java Sound API. I'm using sample code from github and it works perfect on Windows system, but when it runs on MacOS - audio-line buffer returns zero-bytes.

Also if I compile project to jar and run it via administrator permission - appears a message to give access to microphone and after I grant it - all works.

So the question is how to make permission request from code and run app without sudo?

Thanks!

Pitchblende answered 23/8, 2019 at 19:17 Comment(2)
Just compiled this with javac AudioCapture01.java and run with java AudioCapture01 without issue. java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode) on macOS High Sierra. It might be worth checking everything is up to date. and making sure nothing extra has been added to the example code first.Artillery
I have macOS Mojave - working only with rootPitchblende
H
1

BTW, you have to use the default terminal that comes with mac to execute jar file. That will worked.

The third party terminal, such as iTerm, it's not ok.

Hailey answered 27/7, 2020 at 13:29 Comment(2)
Yup, I`m using default terminalPitchblende
Thanks for commenting this. It was driven me crazy.Grocer

© 2022 - 2024 — McMap. All rights reserved.