jpsim / JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!
MIT License
333 stars 90 forks source link

AVF context unavailable nothing happening #57

Open Ajack123 opened 6 years ago

Ajack123 commented 6 years ago

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

}

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.

jlippold commented 6 years ago

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];
}