AirPlay doesn't appear in iOS 10 - ios

SOLVED
With iOS 10.2 AirPlay button has reappeared and it still works. Apple poltergeist!
In iOS 9 I used this code to detect Airplay devices. With deployment target 10.00 it doesn't appear. In Control Center I can find my airplay devices, but in my app the uiview doesn't show anything.
In my capabilities I have checked under "background mode", Audio, AirPlay and picture in picture. Maybe I forget some new setting of this blessed sandbox?
Thanks for your patience
#property (weak, nonatomic) IBOutlet UIView *airplay;
MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: airplay.bounds];
[myVolumeView setShowsVolumeSlider:NO];
[myVolumeView setShowsRouteButton:YES];
myVolumeView.transform = CGAffineTransformMakeScale(0.3,0.3);
[myVolumeView setRouteButtonImage:[UIImage imageNamed:#"myIconAirPlay"] forState:UIControlStateNormal];
[airplay addSubview: myVolumeView];

From apple doc :
If there is an Apple TV or other AirPlay-enabled device in range, the route button allows the user to choose it. If there is only one audio output route available, the route button is not displayed.
https://developer.apple.com/reference/mediaplayer/mpvolumeview
Have you checked if var areWirelessRoutesAvailable: Bool { get } returns true or false on the MPVolumeView ?
I thinks it's the reason why your button is no longer appearing, It wouldn't be new if iOS10 update broke some Airplay devices until they have been updated too.

Related

Disable image recognition for UIImageView on iOS 14 with VoiceOver

I have a UIImageView as the background for a view. User interaction is disabled. isAccessibilityElement is set to NO. This is verified by using debug view hierarchy when the app is running on device.
And yet when I tap on the view that has that as the background is describes all the controls on it and then describes the image using automatic image recognition. Everything I've found online says this is a new iOS 14 feature and that it's great, but says nothing about how I can turn it off.
I even tried setting my own description string to at least try to override the image recognition to no avail. So - IS there a way to turn it off for a specific UIImageView(or even for the app overall) and if so how?
*** update ****
So I've confirmed this is specific to iOS 14. I have the following code in viewDidLoad:
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"blueSky.jpg"]];
imageView.isAccessibilityElement = YES;
imageView.accessibilityLabel = #"I am not a description";
CGPoint origin = imageView.frame.origin;
origin.y = 50;
origin.x = 50;
CGRect imageFrame = imageView.frame;
imageFrame.origin = origin;
imageView.frame = imageFrame;
self.view.isAccessibilityElement = NO;
[self.view addSubview:imageView];
Where blueSky is, well, an image of blue sky. It's not using the asset catalogue. When I tap on the image with VoiceOver enabled in iOS 13 it reads "I am not a description". When I tap on it on an iOS 14.1 device it reads "I am not a description", then pauses for half a second, says "image", then proceeds to describe it "blue sky, cloudy". It's that last part that I cannot for the life of me figure out how to eliminate!
So I found the answer:
imageView.accessibilityTraits = UIAccessibilityTraitNone;
This tells the system to not consider it an image and so it doesn't try to recognize it.

MPVolumeView route button not showing consistently in IOS 11 update

I created IOS app for live streaming with use of AVPlayer. I add the airplay routes button with help of MPVolumeView.
After update of IOS 11, airplay routes button not coming up properly on screen.
Sometime it show on screen sometimes not showing on screen
Anybody help me with it, is it IOS 11 issues or their some change need to MPVolumeView done in my code.
I am using AVPlayerViewController, in which i added MPVolumeView as subview.
self.airButton.frame = CGRect(x:0,y:0,width:45,height:45)
self.airButton.backgroundColor = UIColor.green
let volumeView = MPVolumeView(frame : self.airButton.frame )
volumeView.showsVolumeSlider = false
volumeView.showsRouteButton = true
volumeView.backgroundColor = UIColor.red
self.airButton.addSubview(volumeView)
self.airButton.translatesAutoresizingMaskIntoConstraints = false
self.controlView.addSubview(airButton)
Thanks

How to differentiate apple tv and other devices in airplay?

I am trying to connect apple tv through airplay, but the issue is some time if i connect any other external device like bluetooth or some other device it shows like device connected in window. So i want to identify which device is connected i have to enable only when apple tv is connected.
How can i identify whether it is apple tv or some other device?
This how i create airplay custom button
for (UIButton *button in volumeView.subviews) {
if ([button isKindOfClass:[UIButton class]]) {
self.airplayButton = (UIButton*)button;
button.frame = CGRectMake(0, 0, 30, 23);
button.backgroundColor = [UIColor clearColor];
[self.airplayButton addObserver:self forKeyPath:#"alpha" options:NSKeyValueObservingOptionNew context:nil];
}
}
So the alpha always changes for button even some other devices gets connected.
I've had a look into this before, there's no easily provided way of determining whether the attached device is an Apple TV, there is a Airplay Picker which does this but the code/functions behind it don't seem to be available.
The best you can do it monitor for additional screens being added/removed and then showing your external content only when the screen has the capabilities to do what you need.
I have read somewhere previously that you can get the capabilities of an airplay device and use this information to detect an Apple TV but unfortunately I cannot find it at the moment. If I do find it I'll add a comment.
For now, your best option would be to use the concepts described in this guide
The code provided is in objective-c but its very easily converted to swift, here is the main part you should be looking at
- (void)checkForExistingScreenAndInitializeIfPresent
{
if ([[UIScreen screens] count] > 1)
{
// Get the screen object that represents the external display.
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
// Get the screen's bounds so that you can create a window of the correct size.
CGRect screenBounds = secondScreen.bounds;
self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
self.secondWindow.screen = secondScreen;
// Set up initial content to display...
// Show the window.
self.secondWindow.hidden = NO;
}
}
Like I said you can code this so that it checks the device supports certain resolutions so you can rule out devices that wont support your UI
Some additional resources: https://developer.apple.com/airplay/

How to show Airplay button in MPMoviePlayerController iOS 8

I have an app in which I am playing a video using MPMoviePlayerController with custom controls. I'm adding a feature so that users can mirror the play back in Apple TV for this i have implemented the following code.
MPVolumeView *volumeButton = [[MPVolumeView alloc] initWithFrame:CGRectMake(80.0, 210.0, 160.0, 40.0)];
volumeButton.showsVolumeSlider = NO;
volumeButton.showsRouteButton = YES;
[self.view addSubview:volumeButton];
But Airplay button is not visible in iOS 8. Is there any way to show Airplay button in MPMoviePlayerController?
Please provide your suggestions and valuable inputs.

MPVolumeView with XCode 4 (Storyboards)

How do you make a slider that adjusts the volume level of the device with storyboarding? I haven't found any information on this relevant to XCode 4. Is MPVolumeView still the way to go? If so, how do I implement it?
Thanks.
You can still use an MPVolumeView in Xcode 4.x and iOS5. Simply import the MediaPlayer framework (link to it in your project settings, too) and use something like this:
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0,0,120,15)];
[someView addSubview:volumeView];
This will give you the slider that will change system volume when dragged.
If you want to use a slider, you can add one to your view and link it to an action in the corresponding view controller. The action looks like this:
- (IBAction)volumeSliderChanged:(id)sender
{
UISlider *slider = (UISlider *)sender;
float newVolume = slider.value;
// Set new volume
}

Resources