GithubHelp home page GithubHelp logo

0dbd / jpsvolumebuttonhandler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpsim/jpsvolumebuttonhandler

0.0 1.0 0.0 30 KB

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!

License: MIT License

Ruby 8.93% Objective-C 91.07%

jpsvolumebuttonhandler's Introduction

JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps! Used in JPSImagePickerController.

Features:

  • Run blocks whenever a hardware volume button is pressed
  • Volume button presses don't affect system audio
  • Hide the HUD typically displayed on volume button presses
  • Works even when the system audio level is at its maximum or minimum, even when muted

Installation

From CocoaPods

Add pod 'JPSVolumeButtonHandler' to your Podfile.

Manually

Drag the JPSVolumeButtonHandler folder into your project and link the MediaPlayer and AVFoundation frameworks to your project.

Usage

Set your blocks to be run when the volume buttons are pressed:

self.volumeButtonHandler = [JPSVolumeButtonHandler volumeButtonHandlerWithUpBlock:^{
	// Volume Up Button Pressed
} downBlock:^{
	// Volume Down Button Pressed
}];

To enbable/disable the handler:

// Start
[self.volumeButtonHandler startHandler:YES]; 
// Stop
[self.volumeButtonHandler stopHandler];

To change audio session category (by default AVAudioSessionCategoryPlayAndRecord):

// Set category
self.volumeButtonHandler.sessionCategory = AVAudioSessionCategoryAmbient; 

To change the audio session category options (by default AVAudioSessionCategoryOptionMixWithOthers):

self.volumeButtonHandler.sessionOptions = AVAudioSessionCategoryOptionAllowBluetooth|AVAudioSessionCategoryOptionMixWithOthers;

Note that not all options are compatible with all category options. See AVAudioSession documentation for details.

License

This project is under the MIT license.

jpsvolumebuttonhandler's People

Contributors

apple-ihack-geek avatar atomicbird avatar gliyao avatar jeroenvollenbrock avatar joestelmach avatar jondot avatar jpsim avatar kronik avatar mirceapasoi avatar mrgrauel avatar nolanw avatar rsanchezsaez avatar samyes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.