├── .gitignore ├── .swift-version ├── Demo ├── Demo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Demo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift └── DemoUITests │ ├── DemoUITests.swift │ └── Info.plist ├── Readme.md ├── Screenshots ├── after.png ├── after_iphonex.png └── before.png ├── Volumizer.podspec ├── Volumizer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── Volumizer.xcscheme ├── Volumizer ├── Info.plist ├── Volumizer.h └── Volumizer.swift └── license /.gitignore: -------------------------------------------------------------------------------- 1 | ## Build generated 2 | build/ 3 | DerivedData/ 4 | 5 | ## Various settings 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | 16 | ## Other 17 | *.moved-aside 18 | *.xcuserstate 19 | 20 | ## Obj-C/Swift specific 21 | *.hmap 22 | *.ipa 23 | *.dSYM.zip 24 | *.dSYM 25 | 26 | ## Playgrounds 27 | timeline.xctimeline 28 | playground.xcworkspace 29 | 30 | ## Swift Package Manager 31 | .DS_Store 32 | /.build 33 | /Packages 34 | 35 | ## CocoaPods 36 | Pods/ 37 | 38 | ## Carthage 39 | Carthage/Checkouts 40 | Carthage/Build 41 | 42 | ## Bundler 43 | .bundle 44 | vendor 45 | /Volumizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 46 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.2 -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CF8CA6561E7D0EE70089C627 /* Volumizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF8CA6551E7D0EE70089C627 /* Volumizer.swift */; }; 11 | CFAB10541E7C139F00AA334B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10531E7C139F00AA334B /* AppDelegate.swift */; }; 12 | CFAB10561E7C139F00AA334B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10551E7C139F00AA334B /* ViewController.swift */; }; 13 | CFAB10591E7C139F00AA334B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAB10571E7C139F00AA334B /* Main.storyboard */; }; 14 | CFAB105B1E7C139F00AA334B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFAB105A1E7C139F00AA334B /* Assets.xcassets */; }; 15 | CFAB105E1E7C139F00AA334B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */; }; 16 | CFAB10691E7C139F00AA334B /* DemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10681E7C139F00AA334B /* DemoUITests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | CFAB10651E7C139F00AA334B /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = CFAB10481E7C139F00AA334B /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = CFAB104F1E7C139F00AA334B; 25 | remoteInfo = Demo; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | CF8CA6541E7D0EE70089C627 /* Volumizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Volumizer.h; sourceTree = ""; }; 31 | CF8CA6551E7D0EE70089C627 /* Volumizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Volumizer.swift; sourceTree = ""; }; 32 | CFAB10501E7C139F00AA334B /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | CFAB10531E7C139F00AA334B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | CFAB10551E7C139F00AA334B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 35 | CFAB10581E7C139F00AA334B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | CFAB105A1E7C139F00AA334B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 37 | CFAB105D1E7C139F00AA334B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 38 | CFAB105F1E7C139F00AA334B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | CFAB10641E7C139F00AA334B /* DemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | CFAB10681E7C139F00AA334B /* DemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoUITests.swift; sourceTree = ""; }; 41 | CFAB106A1E7C139F00AA334B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | CFAB104D1E7C139F00AA334B /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | CFAB10611E7C139F00AA334B /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | CF8CA6531E7D0EA80089C627 /* Volumizer */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | CF8CA6541E7D0EE70089C627 /* Volumizer.h */, 66 | CF8CA6551E7D0EE70089C627 /* Volumizer.swift */, 67 | ); 68 | name = Volumizer; 69 | path = ../Volumizer; 70 | sourceTree = ""; 71 | }; 72 | CFAB10471E7C139F00AA334B = { 73 | isa = PBXGroup; 74 | children = ( 75 | CF8CA6531E7D0EA80089C627 /* Volumizer */, 76 | CFAB10521E7C139F00AA334B /* Demo */, 77 | CFAB10671E7C139F00AA334B /* DemoUITests */, 78 | CFAB10511E7C139F00AA334B /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | CFAB10511E7C139F00AA334B /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | CFAB10501E7C139F00AA334B /* Demo.app */, 86 | CFAB10641E7C139F00AA334B /* DemoUITests.xctest */, 87 | ); 88 | name = Products; 89 | sourceTree = ""; 90 | }; 91 | CFAB10521E7C139F00AA334B /* Demo */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | CFAB10531E7C139F00AA334B /* AppDelegate.swift */, 95 | CFAB10551E7C139F00AA334B /* ViewController.swift */, 96 | CFAB10571E7C139F00AA334B /* Main.storyboard */, 97 | CFAB105A1E7C139F00AA334B /* Assets.xcassets */, 98 | CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */, 99 | CFAB105F1E7C139F00AA334B /* Info.plist */, 100 | ); 101 | path = Demo; 102 | sourceTree = ""; 103 | }; 104 | CFAB10671E7C139F00AA334B /* DemoUITests */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | CFAB10681E7C139F00AA334B /* DemoUITests.swift */, 108 | CFAB106A1E7C139F00AA334B /* Info.plist */, 109 | ); 110 | path = DemoUITests; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | CFAB104F1E7C139F00AA334B /* Demo */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = CFAB106D1E7C139F00AA334B /* Build configuration list for PBXNativeTarget "Demo" */; 119 | buildPhases = ( 120 | CFAB104C1E7C139F00AA334B /* Sources */, 121 | CFAB104D1E7C139F00AA334B /* Frameworks */, 122 | CFAB104E1E7C139F00AA334B /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = Demo; 129 | productName = Demo; 130 | productReference = CFAB10501E7C139F00AA334B /* Demo.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | CFAB10631E7C139F00AA334B /* DemoUITests */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = CFAB10701E7C139F00AA334B /* Build configuration list for PBXNativeTarget "DemoUITests" */; 136 | buildPhases = ( 137 | CFAB10601E7C139F00AA334B /* Sources */, 138 | CFAB10611E7C139F00AA334B /* Frameworks */, 139 | CFAB10621E7C139F00AA334B /* Resources */, 140 | ); 141 | buildRules = ( 142 | ); 143 | dependencies = ( 144 | CFAB10661E7C139F00AA334B /* PBXTargetDependency */, 145 | ); 146 | name = DemoUITests; 147 | productName = DemoUITests; 148 | productReference = CFAB10641E7C139F00AA334B /* DemoUITests.xctest */; 149 | productType = "com.apple.product-type.bundle.ui-testing"; 150 | }; 151 | /* End PBXNativeTarget section */ 152 | 153 | /* Begin PBXProject section */ 154 | CFAB10481E7C139F00AA334B /* Project object */ = { 155 | isa = PBXProject; 156 | attributes = { 157 | LastSwiftUpdateCheck = 0820; 158 | LastUpgradeCheck = 1020; 159 | ORGANIZATIONNAME = "Fumitaka Watanabe"; 160 | TargetAttributes = { 161 | CFAB104F1E7C139F00AA334B = { 162 | CreatedOnToolsVersion = 8.2.1; 163 | DevelopmentTeam = Z28NN9BU8E; 164 | LastSwiftMigration = 1020; 165 | ProvisioningStyle = Automatic; 166 | }; 167 | CFAB10631E7C139F00AA334B = { 168 | CreatedOnToolsVersion = 8.2.1; 169 | DevelopmentTeam = Z28NN9BU8E; 170 | LastSwiftMigration = 1020; 171 | ProvisioningStyle = Automatic; 172 | TestTargetID = CFAB104F1E7C139F00AA334B; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = CFAB104B1E7C139F00AA334B /* Build configuration list for PBXProject "Demo" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = en; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | Base, 183 | ); 184 | mainGroup = CFAB10471E7C139F00AA334B; 185 | productRefGroup = CFAB10511E7C139F00AA334B /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | CFAB104F1E7C139F00AA334B /* Demo */, 190 | CFAB10631E7C139F00AA334B /* DemoUITests */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | CFAB104E1E7C139F00AA334B /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | CFAB105E1E7C139F00AA334B /* LaunchScreen.storyboard in Resources */, 201 | CFAB105B1E7C139F00AA334B /* Assets.xcassets in Resources */, 202 | CFAB10591E7C139F00AA334B /* Main.storyboard in Resources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | CFAB10621E7C139F00AA334B /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXResourcesBuildPhase section */ 214 | 215 | /* Begin PBXSourcesBuildPhase section */ 216 | CFAB104C1E7C139F00AA334B /* Sources */ = { 217 | isa = PBXSourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | CF8CA6561E7D0EE70089C627 /* Volumizer.swift in Sources */, 221 | CFAB10561E7C139F00AA334B /* ViewController.swift in Sources */, 222 | CFAB10541E7C139F00AA334B /* AppDelegate.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | CFAB10601E7C139F00AA334B /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | CFAB10691E7C139F00AA334B /* DemoUITests.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXSourcesBuildPhase section */ 235 | 236 | /* Begin PBXTargetDependency section */ 237 | CFAB10661E7C139F00AA334B /* PBXTargetDependency */ = { 238 | isa = PBXTargetDependency; 239 | target = CFAB104F1E7C139F00AA334B /* Demo */; 240 | targetProxy = CFAB10651E7C139F00AA334B /* PBXContainerItemProxy */; 241 | }; 242 | /* End PBXTargetDependency section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | CFAB10571E7C139F00AA334B /* Main.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | CFAB10581E7C139F00AA334B /* Base */, 249 | ); 250 | name = Main.storyboard; 251 | sourceTree = ""; 252 | }; 253 | CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | CFAB105D1E7C139F00AA334B /* Base */, 257 | ); 258 | name = LaunchScreen.storyboard; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | CFAB106B1E7C139F00AA334B /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 269 | CLANG_ANALYZER_NONNULL = YES; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 275 | CLANG_WARN_BOOL_CONVERSION = YES; 276 | CLANG_WARN_COMMA = YES; 277 | CLANG_WARN_CONSTANT_CONVERSION = YES; 278 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 279 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 280 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INFINITE_RECURSION = YES; 284 | CLANG_WARN_INT_CONVERSION = YES; 285 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 287 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 288 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 289 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 290 | CLANG_WARN_STRICT_PROTOTYPES = YES; 291 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 292 | CLANG_WARN_UNREACHABLE_CODE = YES; 293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 294 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 295 | COPY_PHASE_STRIP = NO; 296 | DEBUG_INFORMATION_FORMAT = dwarf; 297 | ENABLE_STRICT_OBJC_MSGSEND = YES; 298 | ENABLE_TESTABILITY = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu99; 300 | GCC_DYNAMIC_NO_PIC = NO; 301 | GCC_NO_COMMON_BLOCKS = YES; 302 | GCC_OPTIMIZATION_LEVEL = 0; 303 | GCC_PREPROCESSOR_DEFINITIONS = ( 304 | "DEBUG=1", 305 | "$(inherited)", 306 | ); 307 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 308 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 309 | GCC_WARN_UNDECLARED_SELECTOR = YES; 310 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 311 | GCC_WARN_UNUSED_FUNCTION = YES; 312 | GCC_WARN_UNUSED_VARIABLE = YES; 313 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 314 | MTL_ENABLE_DEBUG_INFO = YES; 315 | ONLY_ACTIVE_ARCH = YES; 316 | SDKROOT = iphoneos; 317 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 318 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 319 | SWIFT_VERSION = 5.0; 320 | }; 321 | name = Debug; 322 | }; 323 | CFAB106C1E7C139F00AA334B /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 328 | CLANG_ANALYZER_NONNULL = YES; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 334 | CLANG_WARN_BOOL_CONVERSION = YES; 335 | CLANG_WARN_COMMA = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 338 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 339 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INFINITE_RECURSION = YES; 343 | CLANG_WARN_INT_CONVERSION = YES; 344 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 345 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 346 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 348 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 349 | CLANG_WARN_STRICT_PROTOTYPES = YES; 350 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 356 | ENABLE_NS_ASSERTIONS = NO; 357 | ENABLE_STRICT_OBJC_MSGSEND = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_NO_COMMON_BLOCKS = YES; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 370 | SWIFT_VERSION = 5.0; 371 | VALIDATE_PRODUCT = YES; 372 | }; 373 | name = Release; 374 | }; 375 | CFAB106E1E7C139F00AA334B /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | CODE_SIGN_IDENTITY = "iPhone Developer"; 380 | CODE_SIGN_STYLE = Automatic; 381 | DEVELOPMENT_TEAM = Z28NN9BU8E; 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(inherited)", 384 | "$(PROJECT_DIR)/Demo", 385 | ); 386 | INFOPLIST_FILE = Demo/Info.plist; 387 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 389 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Demo; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | PROVISIONING_PROFILE_SPECIFIER = ""; 392 | SWIFT_VERSION = 5.0; 393 | }; 394 | name = Debug; 395 | }; 396 | CFAB106F1E7C139F00AA334B /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 400 | CODE_SIGN_IDENTITY = "iPhone Developer"; 401 | CODE_SIGN_STYLE = Automatic; 402 | DEVELOPMENT_TEAM = Z28NN9BU8E; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(inherited)", 405 | "$(PROJECT_DIR)/Demo", 406 | ); 407 | INFOPLIST_FILE = Demo/Info.plist; 408 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 410 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Demo; 411 | PRODUCT_NAME = "$(TARGET_NAME)"; 412 | PROVISIONING_PROFILE_SPECIFIER = ""; 413 | SWIFT_VERSION = 5.0; 414 | }; 415 | name = Release; 416 | }; 417 | CFAB10711E7C139F00AA334B /* Debug */ = { 418 | isa = XCBuildConfiguration; 419 | buildSettings = { 420 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 421 | DEVELOPMENT_TEAM = Z28NN9BU8E; 422 | FRAMEWORK_SEARCH_PATHS = ( 423 | "$(inherited)", 424 | "$(PROJECT_DIR)/Demo", 425 | ); 426 | INFOPLIST_FILE = DemoUITests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.DemoUITests; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | SWIFT_VERSION = 5.0; 431 | TEST_TARGET_NAME = Demo; 432 | }; 433 | name = Debug; 434 | }; 435 | CFAB10721E7C139F00AA334B /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | buildSettings = { 438 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 439 | DEVELOPMENT_TEAM = Z28NN9BU8E; 440 | FRAMEWORK_SEARCH_PATHS = ( 441 | "$(inherited)", 442 | "$(PROJECT_DIR)/Demo", 443 | ); 444 | INFOPLIST_FILE = DemoUITests/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 446 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.DemoUITests; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | SWIFT_VERSION = 5.0; 449 | TEST_TARGET_NAME = Demo; 450 | }; 451 | name = Release; 452 | }; 453 | /* End XCBuildConfiguration section */ 454 | 455 | /* Begin XCConfigurationList section */ 456 | CFAB104B1E7C139F00AA334B /* Build configuration list for PBXProject "Demo" */ = { 457 | isa = XCConfigurationList; 458 | buildConfigurations = ( 459 | CFAB106B1E7C139F00AA334B /* Debug */, 460 | CFAB106C1E7C139F00AA334B /* Release */, 461 | ); 462 | defaultConfigurationIsVisible = 0; 463 | defaultConfigurationName = Release; 464 | }; 465 | CFAB106D1E7C139F00AA334B /* Build configuration list for PBXNativeTarget "Demo" */ = { 466 | isa = XCConfigurationList; 467 | buildConfigurations = ( 468 | CFAB106E1E7C139F00AA334B /* Debug */, 469 | CFAB106F1E7C139F00AA334B /* Release */, 470 | ); 471 | defaultConfigurationIsVisible = 0; 472 | defaultConfigurationName = Release; 473 | }; 474 | CFAB10701E7C139F00AA334B /* Build configuration list for PBXNativeTarget "DemoUITests" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | CFAB10711E7C139F00AA334B /* Debug */, 478 | CFAB10721E7C139F00AA334B /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | /* End XCConfigurationList section */ 484 | }; 485 | rootObject = CFAB10481E7C139F00AA334B /* Project object */; 486 | } 487 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Demo/Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by Fumitaka Watanabe on 2017/03/17. 6 | // Copyright © 2017年 Fumitaka Watanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | var volumizer: Volumizer? 16 | 17 | internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | return true 21 | } 22 | 23 | func applicationWillResignActive(_ application: UIApplication) { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | func applicationDidEnterBackground(_ application: UIApplication) { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | func applicationWillEnterForeground(_ application: UIApplication) { 34 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | func applicationDidBecomeActive(_ application: UIApplication) { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | func applicationWillTerminate(_ application: UIApplication) { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Demo/Demo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Demo/Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.1.2 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | Necessary for using camera function. 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Demo/Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by Fumitaka Watanabe on 2017/03/17. 6 | // Copyright © 2017年 Fumitaka Watanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var textField: UITextField! 14 | @IBOutlet weak var configureButton: UIButton! 15 | @IBOutlet weak var resultLabel: UILabel! 16 | 17 | var imagePicler: UIImagePickerController? 18 | var volumizer: Volumizer? 19 | let defaultOptions: [VolumizerAppearanceOption] = [ .overlayIsTranslucent(true), 20 | .overlayBackgroundBlurEffectStyle( .extraLight), 21 | .overlayBackgroundColor( .white), 22 | .sliderProgressTintColor( .black)] 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | // Do any additional setup after loading the view, typically from a nib. 27 | 28 | let toolbar = UIToolbar(frame:CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40)) 29 | let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target:nil, action: nil) 30 | let doneButton = UIBarButtonItem(title: "close", style: .done, target: self, action: #selector(resignKeyboard(sender:))) 31 | toolbar.setItems([space, doneButton], animated: true) 32 | textField?.inputAccessoryView = toolbar 33 | } 34 | 35 | override func didReceiveMemoryWarning() { 36 | super.didReceiveMemoryWarning() 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | // MARK: Actions 41 | 42 | @objc func resignKeyboard(sender: UIBarButtonItem) { 43 | textField?.resignFirstResponder() 44 | } 45 | 46 | // MARK: IB Actions 47 | 48 | @IBAction func showAnAlertButtonTapped(_ sender: UIButton) { 49 | let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) 50 | let closeAction = UIAlertAction(title: "Close", style: .default, handler: nil) 51 | alert.addAction(closeAction) 52 | 53 | present(alert, animated: true, completion: nil) 54 | } 55 | 56 | @IBAction func callResignButtonTapped(_ sender: UIButton) { 57 | if let volumizer = volumizer { 58 | defer { self.volumizer = nil } 59 | 60 | volumizer.resign() 61 | configureButton.setTitle("call configure()", for: .normal) 62 | configureButton.setTitleColor( .black, for: .normal) 63 | resultLabel.text = "Before" 64 | } else { 65 | volumizer = Volumizer.configure(defaultOptions) 66 | configureButton.setTitle("call resign()", for: .normal) 67 | configureButton.setTitleColor( .red, for: .normal) 68 | resultLabel.text = "After" 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Demo/DemoUITests/DemoUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemoUITests.swift 3 | // DemoUITests 4 | // 5 | // Created by Fumitaka Watanabe on 2017/03/17. 6 | // Copyright © 2017年 Fumitaka Watanabe. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class DemoUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Demo/DemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Volumizer 2 | [![Platform](https://img.shields.io/cocoapods/p/Volumizer.svg?style=flat)](https://github.com/fxwx23/Volumizer) 3 | [![Language](https://img.shields.io/badge/language-swift-orange.svg?style=flat)](https://developer.apple.com/swift) 4 | [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/Volumizer.svg)](https://cocoapods.org/pods/Volumizer) 5 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 6 | [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/fxwx23/Volumizer/master/license) 7 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md#pull-requests) 8 | 9 | **Volumizer** replaces the system volume popup with a simple progress bar. 10 | 11 | Before | After(No Notch) | After (With Notch) 12 | --- | --- | --- 13 | ![good](https://raw.githubusercontent.com/fxwx23/Volumizer/master/Screenshots/before.png) | ![good](https://raw.githubusercontent.com/fxwx23/Volumizer/master/Screenshots/after.png) | ![good](https://raw.githubusercontent.com/fxwx23/Volumizer/master/Screenshots/after_iphonex.png) 14 | 15 | ### Features 16 | 17 | - Swift 5 18 | - Hide the system volume HUD typically displayed on volume button presses 19 | - Show a simple progress bar like Instagram's iOS app does 20 | - Support iPhoneX, XS, XS Max, XR 21 | - Well easy to customize appearance 22 | - Only support `portrait` mode 23 | 24 | ## Installation 25 | 26 | ##### [CocoaPods](https://cocoapods.org) 27 | ```ruby 28 | platform :ios, '10.0' 29 | use_frameworks! 30 | 31 | pod 'Volumizer' 32 | ``` 33 | ##### [Carthage](https://github.com/Carthage/Carthage) 34 | ``` 35 | github "fxwx23/Volumizer" 36 | ``` 37 | 38 | ##### Manually 39 | Drag the `Volumizer` folder into your project and link the `MediaPlayer` and `AVFoundation` frameworks to your project. 40 | 41 | 42 | ## Usage 43 | Use of `Volumizer` is a simple way with one line. Just call `configure()` after set a window at least. 44 | 45 | ```swift 46 | Volumizer.configure() 47 | ``` 48 | 49 | You can customize the bar's appearance with `VolumizerAppearanceOption`. 50 | 51 | ```swift 52 | /** 53 | public enum VolumizerAppearanceOption { 54 | case overlayIsTranslucent(Bool) default is `true`. 55 | case overlayBackgroundBlurEffectStyle(UIBlurEffectStyle) default is `.extraLight`. 56 | case overlayBackgroundColor(UIColor) default is `.white`. 57 | case sliderProgressTintColor(UIColor) default is `.black`. 58 | case sliderTrackTintColor(UIColor) default is `.lightGray.withAlphaComponent(0.5)` 59 | } 60 | */ 61 | 62 | let options: [VolumizerAppearanceOption] = [ .overlayIsTranslucent(true), 63 | .overlayBackgroundBlurEffect( .extraLight), 64 | .overlayBackgroundColor( .white), 65 | .sliderProgressTintColor( .black)] 66 | 67 | let volumizer = Volumizer.configure(options) 68 | 69 | /// To change options based on view's current appearance, call `change(options:_)` . 70 | volumizer.change(options: otherOptions) 71 | ``` 72 | If you want to release `volumizer` 's window, please call `resign()`. Once you released, the system volume popup will be shown again. 73 | 74 | ```swift 75 | volumizer.resign() 76 | ``` 77 | 78 | ## WIP 79 | - [ ] support `landscape` mode. 80 | - [ ] support [SPM](). 81 | - [ ] manage window level to be below `UIWindowLevelAlert` . 82 | - [ ] `Objective-C` compatible. 83 | 84 | ## License 85 | This project is under the MIT license. 86 | -------------------------------------------------------------------------------- /Screenshots/after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxwx23/Volumizer/44c57063ef71e719d34beef250cea028d3c48555/Screenshots/after.png -------------------------------------------------------------------------------- /Screenshots/after_iphonex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxwx23/Volumizer/44c57063ef71e719d34beef250cea028d3c48555/Screenshots/after_iphonex.png -------------------------------------------------------------------------------- /Screenshots/before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fxwx23/Volumizer/44c57063ef71e719d34beef250cea028d3c48555/Screenshots/before.png -------------------------------------------------------------------------------- /Volumizer.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'Volumizer' 3 | s.version = '1.1.2' 4 | s.platform = :ios, "10.0" 5 | s.license = { :type => "MIT", :file => "license" } 6 | s.summary = 'Volumizer replaces the system volume popup with a simple progress bar.' 7 | s.homepage = 'https://github.com/fxwx23/Volumizer' 8 | s.author = { 'Fumitaka Watanabe' => 'fxwx23@gmail.com' } 9 | s.social_media_url = "https://twitter.com/fxwx23" 10 | s.source = { :git => 'https://github.com/fxwx23/Volumizer.git', :tag => "v#{s.version}" } 11 | s.description = <<-DESC 12 | -Volumizer replaces the system volume popup with a simple progress bar. 13 | -Features 14 | -1. Swift5 15 | -2. Hide the system volume HUD typically displayed on volume button presses 16 | -3. Show a simple progress bar like Instagram's iOS app does 17 | -4. Well easy to customize appearance 18 | -5. Only support portrait mode 19 | DESC 20 | s.source_files = 'Volumizer/*.{h,m,swift}' 21 | s.framework = 'MediaPlayer', 'AVFoundation' 22 | s.requires_arc = true 23 | end 24 | -------------------------------------------------------------------------------- /Volumizer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CF95D34C1E7ABA2E00DD75DD /* Volumizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */; }; 11 | CF95D34F1E7ABA4B00DD75DD /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */; }; 12 | CF95D3511E7ABA6C00DD75DD /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */; }; 13 | CFF0C9ED1E75366C00762C9E /* Volumizer.h in Headers */ = {isa = PBXBuildFile; fileRef = CFF0C9EB1E75366C00762C9E /* Volumizer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Volumizer.swift; sourceTree = ""; }; 18 | CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 19 | CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; 20 | CFF0C9E81E75366C00762C9E /* Volumizer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Volumizer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | CFF0C9EB1E75366C00762C9E /* Volumizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Volumizer.h; sourceTree = ""; }; 22 | CFF0C9EC1E75366C00762C9E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | CFF0C9E41E75366C00762C9E /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | CF95D3511E7ABA6C00DD75DD /* MediaPlayer.framework in Frameworks */, 31 | CF95D34F1E7ABA4B00DD75DD /* AVFoundation.framework in Frameworks */, 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | CF95D34D1E7ABA4A00DD75DD /* Frameworks */ = { 39 | isa = PBXGroup; 40 | children = ( 41 | CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */, 42 | CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */, 43 | ); 44 | name = Frameworks; 45 | sourceTree = ""; 46 | }; 47 | CFF0C9DE1E75366C00762C9E = { 48 | isa = PBXGroup; 49 | children = ( 50 | CFF0C9EA1E75366C00762C9E /* Volumizer */, 51 | CFF0C9E91E75366C00762C9E /* Products */, 52 | CF95D34D1E7ABA4A00DD75DD /* Frameworks */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | CFF0C9E91E75366C00762C9E /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | CFF0C9E81E75366C00762C9E /* Volumizer.framework */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | CFF0C9EA1E75366C00762C9E /* Volumizer */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | CFF0C9EC1E75366C00762C9E /* Info.plist */, 68 | CFF0C9EB1E75366C00762C9E /* Volumizer.h */, 69 | CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */, 70 | ); 71 | path = Volumizer; 72 | sourceTree = ""; 73 | }; 74 | /* End PBXGroup section */ 75 | 76 | /* Begin PBXHeadersBuildPhase section */ 77 | CFF0C9E51E75366C00762C9E /* Headers */ = { 78 | isa = PBXHeadersBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | CFF0C9ED1E75366C00762C9E /* Volumizer.h in Headers */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | /* End PBXHeadersBuildPhase section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | CFF0C9E71E75366C00762C9E /* Volumizer */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = CFF0C9F01E75366C00762C9E /* Build configuration list for PBXNativeTarget "Volumizer" */; 91 | buildPhases = ( 92 | CFF0C9E31E75366C00762C9E /* Sources */, 93 | CFF0C9E41E75366C00762C9E /* Frameworks */, 94 | CFF0C9E51E75366C00762C9E /* Headers */, 95 | CFF0C9E61E75366C00762C9E /* Resources */, 96 | ); 97 | buildRules = ( 98 | ); 99 | dependencies = ( 100 | ); 101 | name = Volumizer; 102 | productName = Volumizer; 103 | productReference = CFF0C9E81E75366C00762C9E /* Volumizer.framework */; 104 | productType = "com.apple.product-type.framework"; 105 | }; 106 | /* End PBXNativeTarget section */ 107 | 108 | /* Begin PBXProject section */ 109 | CFF0C9DF1E75366C00762C9E /* Project object */ = { 110 | isa = PBXProject; 111 | attributes = { 112 | LastUpgradeCheck = 1020; 113 | ORGANIZATIONNAME = "Fumitaka Watanabe"; 114 | TargetAttributes = { 115 | CFF0C9E71E75366C00762C9E = { 116 | CreatedOnToolsVersion = 8.2.1; 117 | DevelopmentTeam = BX6C4637JV; 118 | LastSwiftMigration = 1020; 119 | ProvisioningStyle = Automatic; 120 | }; 121 | }; 122 | }; 123 | buildConfigurationList = CFF0C9E21E75366C00762C9E /* Build configuration list for PBXProject "Volumizer" */; 124 | compatibilityVersion = "Xcode 3.2"; 125 | developmentRegion = en; 126 | hasScannedForEncodings = 0; 127 | knownRegions = ( 128 | en, 129 | Base, 130 | ); 131 | mainGroup = CFF0C9DE1E75366C00762C9E; 132 | productRefGroup = CFF0C9E91E75366C00762C9E /* Products */; 133 | projectDirPath = ""; 134 | projectRoot = ""; 135 | targets = ( 136 | CFF0C9E71E75366C00762C9E /* Volumizer */, 137 | ); 138 | }; 139 | /* End PBXProject section */ 140 | 141 | /* Begin PBXResourcesBuildPhase section */ 142 | CFF0C9E61E75366C00762C9E /* Resources */ = { 143 | isa = PBXResourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXResourcesBuildPhase section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | CFF0C9E31E75366C00762C9E /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | CF95D34C1E7ABA2E00DD75DD /* Volumizer.swift in Sources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXSourcesBuildPhase section */ 161 | 162 | /* Begin XCBuildConfiguration section */ 163 | CFF0C9EE1E75366C00762C9E /* Debug */ = { 164 | isa = XCBuildConfiguration; 165 | buildSettings = { 166 | ALWAYS_SEARCH_USER_PATHS = NO; 167 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 168 | CLANG_ANALYZER_NONNULL = YES; 169 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 170 | CLANG_CXX_LIBRARY = "libc++"; 171 | CLANG_ENABLE_MODULES = YES; 172 | CLANG_ENABLE_OBJC_ARC = YES; 173 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 174 | CLANG_WARN_BOOL_CONVERSION = YES; 175 | CLANG_WARN_COMMA = YES; 176 | CLANG_WARN_CONSTANT_CONVERSION = YES; 177 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 178 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 179 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INFINITE_RECURSION = YES; 183 | CLANG_WARN_INT_CONVERSION = YES; 184 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 185 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 186 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 187 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 188 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 189 | CLANG_WARN_STRICT_PROTOTYPES = YES; 190 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 191 | CLANG_WARN_UNREACHABLE_CODE = YES; 192 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 193 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 194 | COPY_PHASE_STRIP = NO; 195 | CURRENT_PROJECT_VERSION = 1; 196 | DEBUG_INFORMATION_FORMAT = dwarf; 197 | ENABLE_STRICT_OBJC_MSGSEND = YES; 198 | ENABLE_TESTABILITY = YES; 199 | GCC_C_LANGUAGE_STANDARD = gnu99; 200 | GCC_DYNAMIC_NO_PIC = NO; 201 | GCC_NO_COMMON_BLOCKS = YES; 202 | GCC_OPTIMIZATION_LEVEL = 0; 203 | GCC_PREPROCESSOR_DEFINITIONS = ( 204 | "DEBUG=1", 205 | "$(inherited)", 206 | ); 207 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 208 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 209 | GCC_WARN_UNDECLARED_SELECTOR = YES; 210 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 211 | GCC_WARN_UNUSED_FUNCTION = YES; 212 | GCC_WARN_UNUSED_VARIABLE = YES; 213 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 214 | MTL_ENABLE_DEBUG_INFO = YES; 215 | ONLY_ACTIVE_ARCH = YES; 216 | SDKROOT = iphoneos; 217 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 218 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 219 | SWIFT_VERSION = 5.0; 220 | TARGETED_DEVICE_FAMILY = "1,2"; 221 | VERSIONING_SYSTEM = "apple-generic"; 222 | VERSION_INFO_PREFIX = ""; 223 | }; 224 | name = Debug; 225 | }; 226 | CFF0C9EF1E75366C00762C9E /* Release */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 233 | CLANG_CXX_LIBRARY = "libc++"; 234 | CLANG_ENABLE_MODULES = YES; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_COMMA = YES; 239 | CLANG_WARN_CONSTANT_CONVERSION = YES; 240 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 249 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 251 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 252 | CLANG_WARN_STRICT_PROTOTYPES = YES; 253 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 257 | COPY_PHASE_STRIP = NO; 258 | CURRENT_PROJECT_VERSION = 1; 259 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 260 | ENABLE_NS_ASSERTIONS = NO; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | GCC_C_LANGUAGE_STANDARD = gnu99; 263 | GCC_NO_COMMON_BLOCKS = YES; 264 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 265 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 266 | GCC_WARN_UNDECLARED_SELECTOR = YES; 267 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 268 | GCC_WARN_UNUSED_FUNCTION = YES; 269 | GCC_WARN_UNUSED_VARIABLE = YES; 270 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 271 | MTL_ENABLE_DEBUG_INFO = NO; 272 | SDKROOT = iphoneos; 273 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 274 | SWIFT_VERSION = 5.0; 275 | TARGETED_DEVICE_FAMILY = "1,2"; 276 | VALIDATE_PRODUCT = YES; 277 | VERSIONING_SYSTEM = "apple-generic"; 278 | VERSION_INFO_PREFIX = ""; 279 | }; 280 | name = Release; 281 | }; 282 | CFF0C9F11E75366C00762C9E /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | CLANG_ENABLE_MODULES = YES; 286 | CODE_SIGN_IDENTITY = ""; 287 | DEFINES_MODULE = YES; 288 | DEVELOPMENT_TEAM = BX6C4637JV; 289 | DYLIB_COMPATIBILITY_VERSION = 1; 290 | DYLIB_CURRENT_VERSION = 1; 291 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 292 | INFOPLIST_FILE = Volumizer/Info.plist; 293 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 294 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 295 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Volumizer; 296 | PRODUCT_NAME = "$(TARGET_NAME)"; 297 | SKIP_INSTALL = YES; 298 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 299 | SWIFT_VERSION = 5.0; 300 | }; 301 | name = Debug; 302 | }; 303 | CFF0C9F21E75366C00762C9E /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | CLANG_ENABLE_MODULES = YES; 307 | CODE_SIGN_IDENTITY = ""; 308 | DEFINES_MODULE = YES; 309 | DEVELOPMENT_TEAM = BX6C4637JV; 310 | DYLIB_COMPATIBILITY_VERSION = 1; 311 | DYLIB_CURRENT_VERSION = 1; 312 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 313 | INFOPLIST_FILE = Volumizer/Info.plist; 314 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 315 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 316 | PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Volumizer; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | SKIP_INSTALL = YES; 319 | SWIFT_VERSION = 5.0; 320 | }; 321 | name = Release; 322 | }; 323 | /* End XCBuildConfiguration section */ 324 | 325 | /* Begin XCConfigurationList section */ 326 | CFF0C9E21E75366C00762C9E /* Build configuration list for PBXProject "Volumizer" */ = { 327 | isa = XCConfigurationList; 328 | buildConfigurations = ( 329 | CFF0C9EE1E75366C00762C9E /* Debug */, 330 | CFF0C9EF1E75366C00762C9E /* Release */, 331 | ); 332 | defaultConfigurationIsVisible = 0; 333 | defaultConfigurationName = Release; 334 | }; 335 | CFF0C9F01E75366C00762C9E /* Build configuration list for PBXNativeTarget "Volumizer" */ = { 336 | isa = XCConfigurationList; 337 | buildConfigurations = ( 338 | CFF0C9F11E75366C00762C9E /* Debug */, 339 | CFF0C9F21E75366C00762C9E /* Release */, 340 | ); 341 | defaultConfigurationIsVisible = 0; 342 | defaultConfigurationName = Release; 343 | }; 344 | /* End XCConfigurationList section */ 345 | }; 346 | rootObject = CFF0C9DF1E75366C00762C9E /* Project object */; 347 | } 348 | -------------------------------------------------------------------------------- /Volumizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Volumizer.xcodeproj/xcshareddata/xcschemes/Volumizer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Volumizer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.1.2 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Volumizer/Volumizer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Volumizer.h 3 | // Volumizer 4 | // 5 | // Created by Fumitaka Watanabe on 2017/03/12. 6 | // Copyright © 2017年 Fumitaka Watanabe. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Volumizer. 12 | FOUNDATION_EXPORT double VolumizerVersionNumber; 13 | 14 | //! Project version string for Volumizer. 15 | FOUNDATION_EXPORT const unsigned char VolumizerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Volumizer/Volumizer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Volumizer.swift 3 | // Volumizer 4 | // 5 | // Created by Fumitaka Watanabe on 2017/03/16. 6 | // Copyright © 2017年 Fumitaka Watanabe. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import AVFoundation 11 | import MediaPlayer 12 | 13 | fileprivate let AVAudioSessionOutputVolumeKey = "outputVolume" 14 | 15 | /** 16 | Errors being thrown by `VolumizerError`. 17 | - disableToChangeVolumeLevel: `Volumizer` was unable to change audio level 18 | */ 19 | public enum VolumizerError: Error { 20 | case disableToChangeVolumeLevel 21 | } 22 | 23 | /** 24 | VolumizerAppearanceOption 25 | */ 26 | public enum VolumizerAppearanceOption { 27 | case overlayIsTranslucent(Bool) 28 | case overlayBackgroundBlurEffectStyle(UIBlurEffect.Style) 29 | case overlayBackgroundColor(UIColor) 30 | case sliderProgressTintColor(UIColor) 31 | case sliderTrackTintColor(UIColor) 32 | } 33 | 34 | /** 35 | - Volumizer 36 | Replace default `MPVolumeView` by volumizer. 37 | */ 38 | open class Volumizer: UIView { 39 | // MARK: Properties 40 | // current volume value. 41 | public fileprivate(set) var volume: Float = 0 42 | 43 | private let session = AVAudioSession.sharedInstance() 44 | private let volumeView = MPVolumeView(frame: CGRect.zero) 45 | private let overlay = UIView() 46 | private var overlayBlur = UIVisualEffectView() 47 | private var slider = UIProgressView() 48 | private var base: UIWindow? 49 | private var isAppActive = false 50 | private var isAlreadyWindowLevelAboveNormal = false 51 | 52 | // MARK: Initializations 53 | 54 | public convenience init(options: [VolumizerAppearanceOption], base: UIWindow) { 55 | /// default width 56 | self.init(frame: CGRect(x: 0, y: 0, 57 | width: UIScreen.main.bounds.height, 58 | height: UIApplication.shared.statusBarFrame.height)) 59 | self.base = base 60 | isAppActive = true 61 | setupSession(options) 62 | } 63 | 64 | override private init(frame: CGRect) { 65 | super.init(frame: frame) 66 | overlay.frame = frame 67 | } 68 | 69 | required public init() { 70 | fatalError("Please use the convenience initializer `init(options:_, base:_)` instead.") 71 | } 72 | 73 | required public init?(coder aDecoder: NSCoder) { 74 | fatalError("init(coder:) has not been implemented.") 75 | } 76 | 77 | deinit { 78 | session.removeObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, context: nil) 79 | NotificationCenter.default.removeObserver(self) 80 | } 81 | 82 | // MARK: Layout 83 | 84 | open override func layoutSubviews() { 85 | super.layoutSubviews() 86 | let statusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.height 87 | overlay.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: statusBarHeight) 88 | overlayBlur.frame = overlay.bounds 89 | 90 | // Progress view frame is defined based on the device model. 91 | // Slider view style would be like Instagram's way (of course iPhoneX too). 92 | let deviceHasNotch = UIDevice.current.hasNotch 93 | let marginLeft = deviceHasNotch ? (layoutMargins.left * 2) : layoutMargins.left 94 | let top: CGFloat = (overlay.frame.height - slider.frame.height) / 2 95 | let width: CGFloat = deviceHasNotch ? (marginLeft * 2 + statusBarHeight) - marginLeft : overlay.frame.width - (marginLeft * 2) 96 | slider.frame = CGRect(x: marginLeft, y: top, width: width, height: slider.frame.height) 97 | slider.layer.cornerRadius = slider.bounds.height / 2 98 | slider.clipsToBounds = true 99 | } 100 | 101 | // MARK: Convenience 102 | 103 | @discardableResult 104 | open class func configure(_ options: [VolumizerAppearanceOption] = []) -> Volumizer { 105 | let base = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.height, height: UIApplication.shared.statusBarFrame.height)) 106 | base.windowLevel = UIWindow.Level.statusBar + 1.0 107 | 108 | let instance = Volumizer(options: options, base: base) 109 | base.addSubview(instance) 110 | base.makeKeyAndVisible() 111 | 112 | return instance 113 | } 114 | 115 | open func change(options: [VolumizerAppearanceOption]) { 116 | options.forEach { 117 | switch $0 { 118 | case .overlayIsTranslucent(let isTranslucent): 119 | if isTranslucent { 120 | overlayBlur.isHidden = false 121 | } 122 | else { 123 | overlayBlur.isHidden = true 124 | } 125 | case .overlayBackgroundBlurEffectStyle(let style): 126 | overlayBlur.effect = UIBlurEffect(style: style) 127 | case .overlayBackgroundColor(let color): 128 | overlay.backgroundColor = color 129 | backgroundColor = color 130 | case .sliderProgressTintColor(let color): 131 | slider.progressTintColor = color 132 | case .sliderTrackTintColor(let color): 133 | slider.trackTintColor = color 134 | } 135 | } 136 | } 137 | 138 | open func resign() { 139 | base?.resignKey() 140 | base = nil 141 | } 142 | 143 | // MARK: Private 144 | 145 | private func setupSession(_ options: [VolumizerAppearanceOption]) { 146 | do { try session.setCategory( .playback, mode: .default, options: .mixWithOthers) } 147 | catch { print("Unable to set audio session category.") } 148 | 149 | do { try session.setActive(true) } 150 | catch { print("Unable to initialize AVAudioSession.") } 151 | 152 | volumeView.setVolumeThumbImage(UIImage(), for: UIControl.State()) 153 | volumeView.isUserInteractionEnabled = false 154 | volumeView.showsRouteButton = false 155 | addSubview(volumeView) 156 | 157 | /// overlay's `backgroundColor` is white by default. 158 | overlay.backgroundColor = .white 159 | addSubview(overlay) 160 | 161 | overlayBlur = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight)) 162 | overlayBlur.frame = overlay.bounds 163 | overlay.addSubview(overlayBlur) 164 | 165 | /// slider's `thumbTintColor` is black by default. 166 | slider.backgroundColor = .white 167 | slider.progressTintColor = .black 168 | slider.trackTintColor = UIColor.lightGray.withAlphaComponent(0.5) 169 | addSubview(slider) 170 | 171 | change(options: options) 172 | update(volume: session.outputVolume, animated: false) 173 | 174 | /// add observers. 175 | session.addObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, options: .new, context: nil) 176 | NotificationCenter.default.addObserver(self, selector: #selector(audioSessionInterrupted(_:)), name: AVAudioSession.interruptionNotification, object: nil) 177 | NotificationCenter.default.addObserver(self, selector: #selector(audioSessionRouteChanged(_:)), name: AVAudioSession.routeChangeNotification, object: nil) 178 | NotificationCenter.default.addObserver(self, selector: #selector(applicationDidChangeActive(_:)), name: UIApplication.willResignActiveNotification, object: nil) 179 | NotificationCenter.default.addObserver(self, selector: #selector(applicationDidChangeActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil) 180 | NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange(_:)), name: UIDevice.orientationDidChangeNotification, object: nil) 181 | } 182 | 183 | private func update(volume value: Float, animated: Bool) { 184 | volume = value 185 | slider.setProgress(volume, animated: true) 186 | 187 | do { try setSystem(volume: value) } 188 | catch { print("unable to change system volume level.") } 189 | 190 | let deviceHasNotch = UIDevice.current.hasNotch 191 | let animationDuration = deviceHasNotch ? 1.0 : 2.0 192 | let showRelativeDuration = deviceHasNotch ? 0.05 : 0.1 193 | let hideRelativeDuration = deviceHasNotch ? 0.3 : 0.1 194 | UIView.animateKeyframes(withDuration: animated ? animationDuration : 0, delay: 0, options: .beginFromCurrentState, animations: { () -> Void in 195 | UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: showRelativeDuration, animations: { 196 | self.animateProgressView(showing: true) 197 | }) 198 | UIView.addKeyframe(withRelativeStartTime: 0.8, relativeDuration: hideRelativeDuration, animations: { () -> Void in 199 | self.animateProgressView(showing: false) 200 | }) 201 | }) { _ in } 202 | } 203 | 204 | private func setSystem(volume value: Float) throws { 205 | guard let systemSlider = volumeView.subviews.compactMap({ $0 as? UISlider }).first else { 206 | throw VolumizerError.disableToChangeVolumeLevel 207 | } 208 | 209 | systemSlider.value = max(0, min(1, value)) 210 | } 211 | 212 | private func animateProgressView(showing: Bool) { 213 | if showing { 214 | self.alpha = 1 215 | self.base?.transform = CGAffineTransform.identity 216 | } else { 217 | self.alpha = 0.0001 218 | self.base?.transform = UIDevice.current.hasNotch ? 219 | CGAffineTransform.identity : 220 | CGAffineTransform(translationX: 0, y: -self.frame.height) 221 | } 222 | } 223 | 224 | // MARK: Notification 225 | 226 | @objc private func audioSessionInterrupted(_ notification: Notification) { 227 | guard 228 | let interruptionInfo = notification.userInfo, 229 | let rawValue = interruptionInfo[AVAudioSessionInterruptionTypeKey] as? UInt, 230 | let interruptionType = AVAudioSession.InterruptionType(rawValue: rawValue) 231 | else { 232 | return 233 | } 234 | 235 | switch interruptionType { 236 | case .began: 237 | print("Audio Session Interruption: began.") 238 | break 239 | case .ended: 240 | print("Audio Session Interruption: ended.") 241 | do { try session.setActive(true) } 242 | catch { print("Unable to initialize AVAudioSession.") } 243 | @unknown default: 244 | fatalError("unknown AVAudioSessio.InterruptionType is addded.") 245 | } 246 | } 247 | 248 | @objc private func audioSessionRouteChanged(_ notification: Notification) { 249 | guard 250 | let interruptionInfo = notification.userInfo, 251 | let rawValue = interruptionInfo[AVAudioSessionRouteChangeReasonKey] as? UInt, 252 | let reason = AVAudioSession.RouteChangeReason(rawValue: rawValue) 253 | else { 254 | return 255 | } 256 | 257 | switch reason { 258 | case .newDeviceAvailable: 259 | print("Audio seesion route changed: new device available.") 260 | break 261 | case .oldDeviceUnavailable: 262 | print("Audio seesion route changed: old device unavailable.") 263 | break 264 | default: 265 | print("Audio seesion route changed: \(reason.rawValue)") 266 | break 267 | } 268 | } 269 | 270 | @objc private func applicationDidChangeActive(_ notification: Notification) { 271 | isAppActive = notification.name == UIApplication.didBecomeActiveNotification 272 | if isAppActive { 273 | update(volume: session.outputVolume, animated: false) 274 | } 275 | } 276 | 277 | @objc private func orientationDidChange(_ notification: Notification) { 278 | // TODO: [wip] support landscape mode. 279 | // print("orientation changed.") 280 | /** 281 | let currentOrientation = UIDevice.current.orientation 282 | switch currentOrientation { 283 | case .landscapeLeft: 284 | base?.transform = CGAffineTransform(rotationAngle: -CGFloat(90 * M_PI / 180.0)) 285 | case .landscapeRight: 286 | base?.transform = CGAffineTransform(rotationAngle: CGFloat(90 * M_PI / 180.0)) 287 | case .portraitUpsideDown: 288 | base?.transform = CGAffineTransform(rotationAngle: CGFloat(180.0 * M_PI / 180.0)) 289 | default: 290 | base?.transform = CGAffineTransform(rotationAngle: CGFloat(0.0 * M_PI / 180.0)) 291 | } 292 | */ 293 | } 294 | 295 | // MARK: KVO 296 | 297 | open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 298 | guard let change = change, let value = change[.newKey] as? Float , keyPath == AVAudioSessionOutputVolumeKey else { return } 299 | update(volume: value, animated: UIDevice.current.orientation.isPortrait) 300 | } 301 | } 302 | 303 | extension UIDevice { 304 | fileprivate var hasNotch: Bool { 305 | guard let window = UIApplication.shared.keyWindow else { 306 | return false 307 | } 308 | 309 | if #available(iOS 11.0, *) { 310 | return window.safeAreaInsets.bottom > 0.0 && UIDevice.current.userInterfaceIdiom == .phone 311 | } else { 312 | return false 313 | } 314 | } 315 | } 316 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Fumitaka Watanabe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------