I have a (pretty basic) app I have developed which essentially just opens a pre-defined website (via URL) in WebView. It operates nicely in iOS and almost exactly as expected when run on my M1 in macOS with the exception that in macOS it keeps popping up a grey bar which ... after some investigating ... I have determined appears to be the virtual keyboard. Pressing escape clears it however I am trying to find some way of preventing it from coming up in the first place when the app is run in macOS. Is there a (hopefully simple) solution either through code or some app setting for this?
Post
Replies
Boosts
Views
Activity
Hi,
I'm trying to pass audio through from an input directly to the built-in speakers in a macOS app. It's to go along with passing through video to the form. I have successfully populated an AVCaptureDevice object and then initialised an AVCaptureDeviceInput from it. I've then added it as an input to my session. Am I missing something to actually output the session to the speakers though?
Thanks,
Jimmy
-(void) initCaptureSession {
session = [[AVCaptureSession alloc] init];
if ([session canSetSessionPreset : AVCaptureSessionPresetHigh])
[session setSessionPreset : AVCaptureSessionPresetHigh];
if (@available(macOS 10.14, *)) {
if ([AVCaptureDevice authorizationStatusForMediaType: AVMediaTypeVideo] == AVAuthorizationStatusNotDetermined)
{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (granted) {
//self.videoConsentState = PrivacyConsentStateGranted;
}
else {
//self.videoConsentState = PrivacyConsentStateDenied;
}}];
}
} else {
// Fallback on earlier versions
}
AVCaptureDevice *device = nil;
AVCaptureDeviceInput *device_input = nil;
NSArray *devices = [AVCaptureDevice devicesWithMediaType : AVMediaTypeVideo];
for (AVCaptureDevice *dev in devices){
if ([dev.localizedName isEqualToString:@"USB Video"]){
device = dev;
}
}
if (device != nil){
device_input = [[AVCaptureDeviceInput alloc] initWithDevice : device error : nil];
[session addInput : device_input];
}
if (@available(macOS 10.14, *)) {
if ([AVCaptureDevice authorizationStatusForMediaType: AVMediaTypeAudio] == AVAuthorizationStatusNotDetermined)
{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
if (granted) {
//self.microphoneConsentState = PrivacyConsentStateGranted;
}
else {
//self.microphoneConsentState = PrivacyConsentStateDenied;
}}];
}
} else {
// Fallback on earlier versions
}
AVCaptureDevice *audioDevice = nil;
AVCaptureDeviceInput *audioDevice_input = nil;
NSArray *audioDevices = [AVCaptureDevice devicesWithMediaType : AVMediaTypeAudio];
for (AVCaptureDevice *dev in audioDevices){
if ([dev.localizedName isEqualToString:@"USB Digital Audio"]){
audioDevice = dev;
}
}
if (audioDevice != nil){
audioDevice_input = [[AVCaptureDeviceInput alloc] initWithDevice : audioDevice error : nil];
[session addInput : audioDevice_input];
}
}
-(void) setupPreviewLayer {
self.preview_layer = [[AVCaptureVideoPreviewLayer alloc] initWithSession : session];
[self.preview_layer setVideoGravity : AVLayerVideoGravityResizeAspectFill];
[self.preview_layer setFrame : self.view.bounds];
[self.view.layer addSublayer : self.preview_layer];
if (![session isRunning]){
[session startRunning];
}
}