Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to customize the Airplay button when airplay is active
    primarykey
    data
    text
    <p>Been trying to solve this issue for 2 days now and I give up. Im trying to implement a customized airplay button (I have to beacuse the background is white and the button must be black). Ive added a view in interfacebuilder and chose mpVolumeView for it. Then I made the connections and wrote the following code; </p> <pre><code>viewDidLoad.. { ..... [_volumeView setShowsVolumeSlider:NO]; for (UIButton *button in _volumeView.subviews) { if ([button isKindOfClass:[UIButton class]]) { [button setImage:[UIImage imageNamed:@"airplay_icon.png"] forState:UIControlStateNormal]; [button addObserver:self forKeyPath:@"alpha" options:NSKeyValueObservingOptionNew context:nil]; [button addTarget:self action:@selector(switchAirplayButton) forControlEvents:UIControlEventTouchUpInside]; [button sizeToFit]; } } [_volumeView sizeToFit]; } -(void)switchAirplayButton { for (UIButton *button in _volumeView.subviews) { if ([button isKindOfClass:[UIButton class]]) { NSLog(@"%d", _controlBar.player.airPlayVideoActive); if(_controlBar.player.airPlayVideoActive) { [button setImage:[UIImage imageNamed:@"airplay_icon_pressed.png"] forState:UIControlStateNormal]; } else [button setImage:[UIImage imageNamed:@"airplay_icon.png"] forState:UIControlStateNormal]; [button sizeToFit]; } } } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([object isKindOfClass:[UIButton class]] &amp;&amp; [[change valueForKey:NSKeyValueChangeNewKey] intValue] == 1) { [(UIButton *)object setImage:[UIImage imageNamed:@"airplay_icon.png"] forState:UIControlStateNormal]; [(UIButton *)object sizeToFit]; } } </code></pre> <p>The "player" is a singelton based on AVPLayer. However, it always returns false when checking if airPlay is active. Maybe it's just beacuse im using sound, not video. </p> <p>So my question is, how could I change the button to... lets say an orange one (just to match the rest of the interface) when airplay is streaming (just like apple is making it blue). I have tried everything and it's just not working at all. Please help me. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload