teamclouday / AndroidMic

Use your Android phone as a mic to Windows PC
MIT License
113 stars 9 forks source link

Mic stop recording after 1 min #14

Closed wiiznokes closed 1 year ago

wiiznokes commented 1 year ago

The service seems to pause itself after 1 min when the app is minimized. Then if we reopen the app, the stream work as expected.

teamclouday commented 1 year ago

Was the phone screen locked? I just tested on main branch and the minimized app does not affect the service.\ But if the phone was locked, the service was dead, until I unlock the phone. And this is because that foreground service (which sends audio data) was dead when the activity is down for a while.

wiiznokes commented 1 year ago

When the phone screen is unlocked.

teamclouday commented 1 year ago

Hmm... this will be hard to debug. Could you double click on the audio display to hide it and then test with minimized app?\ My quick guess is that the GUI rendering was turned off while the app was updating the audio waves.

wiiznokes commented 1 year ago

I figured out what was the problem. We need to specified the service will use microphone as is mentioned here . So just add startForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE, notification in onCreateof ForegroundService will solve the issue.

wiiznokes commented 1 year ago

Just tried and it's work even better as expect (even when the screen is locked)

teamclouday commented 1 year ago

Sounds great! I'll try it. Please submit a PR for this!