JPSVolumeButtonHandler icon indicating copy to clipboard operation
JPSVolumeButtonHandler copied to clipboard

AVF context unavailable nothing happening

Open Ajack123 opened this issue 7 years ago • 1 comments

Hi there jpsim While searching the Internet for a volume button handler I stumbled upon your code here. I really need your code and tried to run it in Xcode but during simulation I get the following message:

2018-04-01 11:11:11.082845-0700 Buttons[11228:255620] [MediaRemote] [AVOutputContext] WARNING: AVF context unavailable for sharedAudioPresentationContext 2018-04-01 11:11:11.087537-0700 Buttons[11228:255620] [MediaRemote] [AVOutputContext] WARNING: AVF context unavailable for +[MRAVOutputContext createOutputContextWithUniqueIdentifier:]

I have to admit that I really do not know objective c but I was pretty sure that I did everything you've said.I've added the frameworks in my settings,too

#import "helloViewController.h" #import <AVFoundation/AVFoundation.h> #import <MediaPlayer/MediaPlayer.h> #import "SystemVolumeView.h"

#import "JPSVolumeButtonHandler.h" //here importer

@interface helloViewController ()

@property (nonatomic,strong) JPSVolumeButtonHandler *volumeButtonHandler;// declared

@end

@implementation helloViewController

  • (void)viewDidLoad { [super viewDidLoad];

    [self.volumeButtonHandler stopHandler]; // just to make sure but also tried without this line [self.volumeButtonHandler startHandler:YES];

}

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

  • (IBAction)showMessage //click button to see if it works then it should listen for button press { NSLog(@"Something"); self.volumeButtonHandler = [JPSVolumeButtonHandler volumeButtonHandlerWithUpBlock:^{ // Volume Up Button Pressed NSLog(@"Volume Up Button Pressed");

    } downBlock:^{ // Volume Down Button Pressed NSLog(@"Volume Down Button Pressed");

    }];}

your code is very crucial for me. I've already implemented this feature for my android app version but I'm struggling with iOS. All other objective c codes on the internet are outdated. they worked until iOS 7.

Thanks in advance.

Ajack123 avatar Apr 01 '18 18:04 Ajack123

Try this, it works for me:

- (void)viewDidLoad {
    self.volumeButtonHandler = [[JPSVolumeButtonHandler alloc] init];
    self.volumeButtonHandler = [JPSVolumeButtonHandler volumeButtonHandlerWithUpBlock:^{
        // Volume Up Button Pressed
        NSLog(@"UP");
    } downBlock:^{
        // Volume Down Button Pressed
        NSLog(@"Down");
    }];
    
    [self.volumeButtonHandler startHandler:YES];
    [self.volumeButtonHandler useExactJumpsOnly:YES];
}

jlippold avatar Apr 20 '18 17:04 jlippold