Eh, I think my code works, if I select the speaker. I thought I was getting 
partial volume but i think I was getting full volume from the ear speaker.  
Curious to note: there is no way in Qt to do this, have to drop into 
AVFoundation to do that.
One of the many missing mobile features...

> Sent: Wednesday, October 16, 2019 at 3:43 PM
> From: "Jason H" <jh...@gmx.com>
> To: "interestqt-project.org" <interest@qt-project.org>
> Subject: [Interest] iOS device volume control on iOS 12+ with Qt
>
> This solution had been working for me:
> https://stackoverflow.com/questions/50737943/how-to-change-volume-programmatically-on-ios-11-4/50740074#50740074
>
> But it seems that I can't get away with an MPVolumeView anymore. However the 
> proposed solution isn't working for me as I am not sure how to patch that 
> into a Qt iOS app.
> [UIApplication sharedApplication].windows is an array, but I am not sure what 
> dragons are there with Qt.
>
> Anyway, even patching in [UIApplication sharedApplication].windows[0] doesn't 
> seem to be working.
> I don't care about hiding the MPVolumeView. I just need it to work
>
> void setVolume(double volume){
>       UIWindow *mainWindow = [UIApplication sharedApplication].windows[0];
>       //UIView *mainWindow = [UIView new];
>       MPVolumeView *volumeView = [MPVolumeView new];
>       UISlider *volumeViewSlider = nil;
>       [mainWindow addSubview:volumeView];
>
>       for (UIView *view in volumeView.subviews) {
>         if ([view isKindOfClass:[UISlider class]]) {
>               volumeViewSlider = (UISlider *)view;
>               break;
>         }
>       }
>       if (volumeViewSlider != nil) {
>               dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 
> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
>                       volumeViewSlider.value = volume;
>                       NSLog(@"volumeViewSlider  set to %1.3f", volume);
>               });
>       } else {
>               NSLog(@"volumeViewSlider is nil");
>       }
> }
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to