├── JxbPlayerControl.podspec ├── JxbPlayerControl.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── Peter.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Peter.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── JxbPlayerControl.xcscheme │ └── xcschememanagement.plist ├── JxbPlayerControl ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── icon_back.imageset │ │ ├── Contents.json │ │ ├── icon_back@2x.png │ │ └── icon_back@3x.png │ ├── icon_next.imageset │ │ ├── Contents.json │ │ ├── icon_next@2x.png │ │ └── icon_next@3x.png │ ├── icon_pause.imageset │ │ ├── Contents.json │ │ ├── icon_pause@2x.png │ │ └── icon_pause@3x.png │ ├── icon_play.imageset │ │ ├── Contents.json │ │ ├── icon_play@2x.png │ │ └── icon_play@3x.png │ └── icon_refresh.imageset │ │ ├── Contents.json │ │ ├── icon_refresh@2x.png │ │ └── icon_refresh@3x-1.png ├── Info.plist ├── JxbPlayer │ ├── JxbPlayer.h │ └── JxbPlayer.m ├── ViewController.h ├── ViewController.m └── main.m ├── JxbPlayerControlTests ├── Info.plist └── JxbPlayerControlTests.m ├── LICENSE ├── README.md └── screenshot.gif /JxbPlayerControl.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "JxbPlayerControl" 4 | s.version = "1.0" 5 | s.summary = "Mp3 Player Control" 6 | s.homepage = "https://github.com/JxbSir" 7 | s.license = "Peter" 8 | s.author = { "Peter" => "i@jxb.name" } 9 | s.requires_arc = true 10 | s.source = { :git => "https://github.com/JxbSir/JxbPlayerControl.git" } 11 | s.source_files = "JxbPlayerControl/JxbPlayer/*.{h,m}" 12 | s.public_header_files = 'JxbPlayerControl/JxbPlayer/JxbPlayer.h' 13 | s.frameworks = 'UIKit' 14 | end 15 | -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D08C9C401B2FC02500F0FC3C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D08C9C3F1B2FC02500F0FC3C /* main.m */; }; 11 | D08C9C431B2FC02500F0FC3C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D08C9C421B2FC02500F0FC3C /* AppDelegate.m */; }; 12 | D08C9C461B2FC02500F0FC3C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D08C9C451B2FC02500F0FC3C /* ViewController.m */; }; 13 | D08C9C491B2FC02500F0FC3C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D08C9C471B2FC02500F0FC3C /* Main.storyboard */; }; 14 | D08C9C4B1B2FC02500F0FC3C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D08C9C4A1B2FC02500F0FC3C /* Images.xcassets */; }; 15 | D08C9C4E1B2FC02500F0FC3C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D08C9C4C1B2FC02500F0FC3C /* LaunchScreen.xib */; }; 16 | D08C9C5A1B2FC02500F0FC3C /* JxbPlayerControlTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D08C9C591B2FC02500F0FC3C /* JxbPlayerControlTests.m */; }; 17 | D08C9C661B2FC04600F0FC3C /* JxbPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = D08C9C651B2FC04600F0FC3C /* JxbPlayer.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | D08C9C541B2FC02500F0FC3C /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = D08C9C321B2FC02500F0FC3C /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = D08C9C391B2FC02500F0FC3C; 26 | remoteInfo = JxbPlayerControl; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | D08C9C3A1B2FC02500F0FC3C /* JxbPlayerControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JxbPlayerControl.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | D08C9C3E1B2FC02500F0FC3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | D08C9C3F1B2FC02500F0FC3C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | D08C9C411B2FC02500F0FC3C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | D08C9C421B2FC02500F0FC3C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | D08C9C441B2FC02500F0FC3C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | D08C9C451B2FC02500F0FC3C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | D08C9C481B2FC02500F0FC3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | D08C9C4A1B2FC02500F0FC3C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | D08C9C4D1B2FC02500F0FC3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | D08C9C531B2FC02500F0FC3C /* JxbPlayerControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JxbPlayerControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | D08C9C581B2FC02500F0FC3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | D08C9C591B2FC02500F0FC3C /* JxbPlayerControlTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JxbPlayerControlTests.m; sourceTree = ""; }; 44 | D08C9C641B2FC04600F0FC3C /* JxbPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JxbPlayer.h; sourceTree = ""; }; 45 | D08C9C651B2FC04600F0FC3C /* JxbPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JxbPlayer.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | D08C9C371B2FC02500F0FC3C /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | D08C9C501B2FC02500F0FC3C /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | D08C9C311B2FC02500F0FC3C = { 67 | isa = PBXGroup; 68 | children = ( 69 | D08C9C3C1B2FC02500F0FC3C /* JxbPlayerControl */, 70 | D08C9C561B2FC02500F0FC3C /* JxbPlayerControlTests */, 71 | D08C9C3B1B2FC02500F0FC3C /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | D08C9C3B1B2FC02500F0FC3C /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | D08C9C3A1B2FC02500F0FC3C /* JxbPlayerControl.app */, 79 | D08C9C531B2FC02500F0FC3C /* JxbPlayerControlTests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | D08C9C3C1B2FC02500F0FC3C /* JxbPlayerControl */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | D08C9C631B2FC04600F0FC3C /* JxbPlayer */, 88 | D08C9C411B2FC02500F0FC3C /* AppDelegate.h */, 89 | D08C9C421B2FC02500F0FC3C /* AppDelegate.m */, 90 | D08C9C441B2FC02500F0FC3C /* ViewController.h */, 91 | D08C9C451B2FC02500F0FC3C /* ViewController.m */, 92 | D08C9C471B2FC02500F0FC3C /* Main.storyboard */, 93 | D08C9C4A1B2FC02500F0FC3C /* Images.xcassets */, 94 | D08C9C4C1B2FC02500F0FC3C /* LaunchScreen.xib */, 95 | D08C9C3D1B2FC02500F0FC3C /* Supporting Files */, 96 | ); 97 | path = JxbPlayerControl; 98 | sourceTree = ""; 99 | }; 100 | D08C9C3D1B2FC02500F0FC3C /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | D08C9C3E1B2FC02500F0FC3C /* Info.plist */, 104 | D08C9C3F1B2FC02500F0FC3C /* main.m */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | D08C9C561B2FC02500F0FC3C /* JxbPlayerControlTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | D08C9C591B2FC02500F0FC3C /* JxbPlayerControlTests.m */, 113 | D08C9C571B2FC02500F0FC3C /* Supporting Files */, 114 | ); 115 | path = JxbPlayerControlTests; 116 | sourceTree = ""; 117 | }; 118 | D08C9C571B2FC02500F0FC3C /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | D08C9C581B2FC02500F0FC3C /* Info.plist */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | D08C9C631B2FC04600F0FC3C /* JxbPlayer */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | D08C9C641B2FC04600F0FC3C /* JxbPlayer.h */, 130 | D08C9C651B2FC04600F0FC3C /* JxbPlayer.m */, 131 | ); 132 | path = JxbPlayer; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | D08C9C391B2FC02500F0FC3C /* JxbPlayerControl */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = D08C9C5D1B2FC02500F0FC3C /* Build configuration list for PBXNativeTarget "JxbPlayerControl" */; 141 | buildPhases = ( 142 | D08C9C361B2FC02500F0FC3C /* Sources */, 143 | D08C9C371B2FC02500F0FC3C /* Frameworks */, 144 | D08C9C381B2FC02500F0FC3C /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = JxbPlayerControl; 151 | productName = JxbPlayerControl; 152 | productReference = D08C9C3A1B2FC02500F0FC3C /* JxbPlayerControl.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | D08C9C521B2FC02500F0FC3C /* JxbPlayerControlTests */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = D08C9C601B2FC02500F0FC3C /* Build configuration list for PBXNativeTarget "JxbPlayerControlTests" */; 158 | buildPhases = ( 159 | D08C9C4F1B2FC02500F0FC3C /* Sources */, 160 | D08C9C501B2FC02500F0FC3C /* Frameworks */, 161 | D08C9C511B2FC02500F0FC3C /* Resources */, 162 | ); 163 | buildRules = ( 164 | ); 165 | dependencies = ( 166 | D08C9C551B2FC02500F0FC3C /* PBXTargetDependency */, 167 | ); 168 | name = JxbPlayerControlTests; 169 | productName = JxbPlayerControlTests; 170 | productReference = D08C9C531B2FC02500F0FC3C /* JxbPlayerControlTests.xctest */; 171 | productType = "com.apple.product-type.bundle.unit-test"; 172 | }; 173 | /* End PBXNativeTarget section */ 174 | 175 | /* Begin PBXProject section */ 176 | D08C9C321B2FC02500F0FC3C /* Project object */ = { 177 | isa = PBXProject; 178 | attributes = { 179 | LastUpgradeCheck = 0630; 180 | ORGANIZATIONNAME = Peter; 181 | TargetAttributes = { 182 | D08C9C391B2FC02500F0FC3C = { 183 | CreatedOnToolsVersion = 6.3.2; 184 | }; 185 | D08C9C521B2FC02500F0FC3C = { 186 | CreatedOnToolsVersion = 6.3.2; 187 | TestTargetID = D08C9C391B2FC02500F0FC3C; 188 | }; 189 | }; 190 | }; 191 | buildConfigurationList = D08C9C351B2FC02500F0FC3C /* Build configuration list for PBXProject "JxbPlayerControl" */; 192 | compatibilityVersion = "Xcode 3.2"; 193 | developmentRegion = English; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | Base, 198 | ); 199 | mainGroup = D08C9C311B2FC02500F0FC3C; 200 | productRefGroup = D08C9C3B1B2FC02500F0FC3C /* Products */; 201 | projectDirPath = ""; 202 | projectRoot = ""; 203 | targets = ( 204 | D08C9C391B2FC02500F0FC3C /* JxbPlayerControl */, 205 | D08C9C521B2FC02500F0FC3C /* JxbPlayerControlTests */, 206 | ); 207 | }; 208 | /* End PBXProject section */ 209 | 210 | /* Begin PBXResourcesBuildPhase section */ 211 | D08C9C381B2FC02500F0FC3C /* Resources */ = { 212 | isa = PBXResourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | D08C9C491B2FC02500F0FC3C /* Main.storyboard in Resources */, 216 | D08C9C4E1B2FC02500F0FC3C /* LaunchScreen.xib in Resources */, 217 | D08C9C4B1B2FC02500F0FC3C /* Images.xcassets in Resources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | D08C9C511B2FC02500F0FC3C /* Resources */ = { 222 | isa = PBXResourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXResourcesBuildPhase section */ 229 | 230 | /* Begin PBXSourcesBuildPhase section */ 231 | D08C9C361B2FC02500F0FC3C /* Sources */ = { 232 | isa = PBXSourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | D08C9C661B2FC04600F0FC3C /* JxbPlayer.m in Sources */, 236 | D08C9C461B2FC02500F0FC3C /* ViewController.m in Sources */, 237 | D08C9C431B2FC02500F0FC3C /* AppDelegate.m in Sources */, 238 | D08C9C401B2FC02500F0FC3C /* main.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | D08C9C4F1B2FC02500F0FC3C /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | D08C9C5A1B2FC02500F0FC3C /* JxbPlayerControlTests.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | D08C9C551B2FC02500F0FC3C /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | target = D08C9C391B2FC02500F0FC3C /* JxbPlayerControl */; 256 | targetProxy = D08C9C541B2FC02500F0FC3C /* PBXContainerItemProxy */; 257 | }; 258 | /* End PBXTargetDependency section */ 259 | 260 | /* Begin PBXVariantGroup section */ 261 | D08C9C471B2FC02500F0FC3C /* Main.storyboard */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | D08C9C481B2FC02500F0FC3C /* Base */, 265 | ); 266 | name = Main.storyboard; 267 | sourceTree = ""; 268 | }; 269 | D08C9C4C1B2FC02500F0FC3C /* LaunchScreen.xib */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | D08C9C4D1B2FC02500F0FC3C /* Base */, 273 | ); 274 | name = LaunchScreen.xib; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | D08C9C5B1B2FC02500F0FC3C /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | GCC_C_LANGUAGE_STANDARD = gnu99; 302 | GCC_DYNAMIC_NO_PIC = NO; 303 | GCC_NO_COMMON_BLOCKS = YES; 304 | GCC_OPTIMIZATION_LEVEL = 0; 305 | GCC_PREPROCESSOR_DEFINITIONS = ( 306 | "DEBUG=1", 307 | "$(inherited)", 308 | ); 309 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 317 | MTL_ENABLE_DEBUG_INFO = YES; 318 | ONLY_ACTIVE_ARCH = YES; 319 | SDKROOT = iphoneos; 320 | }; 321 | name = Debug; 322 | }; 323 | D08C9C5C1B2FC02500F0FC3C /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INT_CONVERSION = YES; 337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 338 | CLANG_WARN_UNREACHABLE_CODE = YES; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 341 | COPY_PHASE_STRIP = NO; 342 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 343 | ENABLE_NS_ASSERTIONS = NO; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_NO_COMMON_BLOCKS = YES; 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 354 | MTL_ENABLE_DEBUG_INFO = NO; 355 | SDKROOT = iphoneos; 356 | VALIDATE_PRODUCT = YES; 357 | }; 358 | name = Release; 359 | }; 360 | D08C9C5E1B2FC02500F0FC3C /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | INFOPLIST_FILE = JxbPlayerControl/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | }; 368 | name = Debug; 369 | }; 370 | D08C9C5F1B2FC02500F0FC3C /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 374 | INFOPLIST_FILE = JxbPlayerControl/Info.plist; 375 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 376 | PRODUCT_NAME = "$(TARGET_NAME)"; 377 | }; 378 | name = Release; 379 | }; 380 | D08C9C611B2FC02500F0FC3C /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | BUNDLE_LOADER = "$(TEST_HOST)"; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(SDKROOT)/Developer/Library/Frameworks", 386 | "$(inherited)", 387 | ); 388 | GCC_PREPROCESSOR_DEFINITIONS = ( 389 | "DEBUG=1", 390 | "$(inherited)", 391 | ); 392 | INFOPLIST_FILE = JxbPlayerControlTests/Info.plist; 393 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 394 | PRODUCT_NAME = "$(TARGET_NAME)"; 395 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JxbPlayerControl.app/JxbPlayerControl"; 396 | }; 397 | name = Debug; 398 | }; 399 | D08C9C621B2FC02500F0FC3C /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | BUNDLE_LOADER = "$(TEST_HOST)"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(SDKROOT)/Developer/Library/Frameworks", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = JxbPlayerControlTests/Info.plist; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JxbPlayerControl.app/JxbPlayerControl"; 411 | }; 412 | name = Release; 413 | }; 414 | /* End XCBuildConfiguration section */ 415 | 416 | /* Begin XCConfigurationList section */ 417 | D08C9C351B2FC02500F0FC3C /* Build configuration list for PBXProject "JxbPlayerControl" */ = { 418 | isa = XCConfigurationList; 419 | buildConfigurations = ( 420 | D08C9C5B1B2FC02500F0FC3C /* Debug */, 421 | D08C9C5C1B2FC02500F0FC3C /* Release */, 422 | ); 423 | defaultConfigurationIsVisible = 0; 424 | defaultConfigurationName = Release; 425 | }; 426 | D08C9C5D1B2FC02500F0FC3C /* Build configuration list for PBXNativeTarget "JxbPlayerControl" */ = { 427 | isa = XCConfigurationList; 428 | buildConfigurations = ( 429 | D08C9C5E1B2FC02500F0FC3C /* Debug */, 430 | D08C9C5F1B2FC02500F0FC3C /* Release */, 431 | ); 432 | defaultConfigurationIsVisible = 0; 433 | }; 434 | D08C9C601B2FC02500F0FC3C /* Build configuration list for PBXNativeTarget "JxbPlayerControlTests" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | D08C9C611B2FC02500F0FC3C /* Debug */, 438 | D08C9C621B2FC02500F0FC3C /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | }; 442 | /* End XCConfigurationList section */ 443 | }; 444 | rootObject = D08C9C321B2FC02500F0FC3C /* Project object */; 445 | } 446 | -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/project.xcworkspace/xcuserdata/Peter.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl.xcodeproj/project.xcworkspace/xcuserdata/Peter.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/xcuserdata/Peter.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/xcuserdata/Peter.xcuserdatad/xcschemes/JxbPlayerControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /JxbPlayerControl.xcodeproj/xcuserdata/Peter.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JxbPlayerControl.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D08C9C391B2FC02500F0FC3C 16 | 17 | primary 18 | 19 | 20 | D08C9C521B2FC02500F0FC3C 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JxbPlayerControl/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JxbPlayerControl 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /JxbPlayerControl/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JxbPlayerControl 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 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 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 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 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /JxbPlayerControl/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /JxbPlayerControl/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 | -------------------------------------------------------------------------------- /JxbPlayerControl/Images.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 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_back.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "icon_back@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "icon_back@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_back.imageset/icon_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_back.imageset/icon_back@2x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_back.imageset/icon_back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_back.imageset/icon_back@3x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_next.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "icon_next@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "icon_next@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_next.imageset/icon_next@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_next.imageset/icon_next@2x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_next.imageset/icon_next@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_next.imageset/icon_next@3x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_pause.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "icon_pause@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "icon_pause@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_pause.imageset/icon_pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_pause.imageset/icon_pause@2x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_pause.imageset/icon_pause@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_pause.imageset/icon_pause@3x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_play.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "icon_play@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "icon_play@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_play.imageset/icon_play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_play.imageset/icon_play@2x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_play.imageset/icon_play@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_play.imageset/icon_play@3x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_refresh.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "icon_refresh@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "icon_refresh@3x-1.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_refresh.imageset/icon_refresh@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_refresh.imageset/icon_refresh@2x.png -------------------------------------------------------------------------------- /JxbPlayerControl/Images.xcassets/icon_refresh.imageset/icon_refresh@3x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/JxbPlayerControl/Images.xcassets/icon_refresh.imageset/icon_refresh@3x-1.png -------------------------------------------------------------------------------- /JxbPlayerControl/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | net.fanwa.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 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 | -------------------------------------------------------------------------------- /JxbPlayerControl/JxbPlayer/JxbPlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // JxbPlayer.h 3 | // VOA 4 | // 5 | // Created by Peter on 15/6/1. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (Size) 12 | - (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode; 13 | @end 14 | 15 | @protocol JxbPlayerDelegate 16 | - (void)XBPlayer_play; 17 | - (void)XBPlayer_pause; 18 | - (void)XBPlayer_stop; 19 | - (void)XBPlayer_playDuration:(NSTimeInterval)duration; 20 | @end 21 | 22 | @interface JxbPlayer : UIControl 23 | @property(nonatomic,assign)id delegate; 24 | /** 25 | * set mp3 url 26 | */ 27 | @property(nonatomic,copy)NSString* itemUrl; 28 | 29 | 30 | - (id)initWithMainColor:(UIColor*)color frame:(CGRect)frame; 31 | 32 | /** 33 | * start play 34 | */ 35 | - (void)play; 36 | 37 | /** 38 | * stop play 39 | */ 40 | - (void)stop; 41 | @end 42 | -------------------------------------------------------------------------------- /JxbPlayerControl/JxbPlayer/JxbPlayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // JxbPlayer.m 3 | // VOA 4 | // 5 | // Created by Peter on 15/6/1. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import "JxbPlayer.h" 10 | #import 11 | #import 12 | 13 | #define playerScale 44100 14 | #define playerIconWidth 36 15 | #define playerFont [UIFont systemFontOfSize:16] 16 | 17 | 18 | @implementation NSString (Size) 19 | - (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode 20 | { 21 | CGSize textSize; 22 | if (CGSizeEqualToSize(size, CGSizeZero)) 23 | { 24 | NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; 25 | textSize = [self sizeWithAttributes:attributes]; 26 | } 27 | else 28 | { 29 | NSStringDrawingOptions option = NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading; 30 | //NSStringDrawingTruncatesLastVisibleLine如果文本内容超出指定的矩形限制,文本将被截去并在最后一个字符后加上省略号。 如果指定了NSStringDrawingUsesLineFragmentOrigin选项,则该选项被忽略 NSStringDrawingUsesFontLeading计算行高时使用行间距。(译者注:字体大小+行间距=行高) 31 | NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; 32 | CGRect rect = [self boundingRectWithSize:size 33 | options:option 34 | attributes:attributes 35 | context:nil]; 36 | 37 | textSize = rect.size; 38 | } 39 | return textSize; 40 | } 41 | @end 42 | 43 | @interface JxbPlayer() 44 | @property(nonatomic,copy)UIColor *maincolor; 45 | @property(nonatomic,strong)AVPlayer *avPlayer; 46 | @property(nonatomic,strong)AVPlayerItem *avItem; 47 | @property(nonatomic,strong)NSTimer *avTimer; 48 | @property(nonatomic,assign)BOOL bBegin; 49 | @property(nonatomic,assign)BOOL bStop; 50 | @property(nonatomic,assign)BOOL bSliderDragging; 51 | @property(nonatomic,assign)BOOL bPausing; 52 | @property(nonatomic,assign)BOOL bLoadFinish; 53 | 54 | @property(nonatomic,strong)UIButton *btnPlay; 55 | @property(nonatomic,strong)UIButton *btnNext; 56 | @property(nonatomic,strong)UIButton *btnBack; 57 | @property(nonatomic,strong)UILabel *lblPlayTime; 58 | @property(nonatomic,strong)UILabel *lblAllTime; 59 | @property(nonatomic,strong)UISlider *slider; 60 | @property(nonatomic,strong)UIView *vDownProgress; 61 | @end 62 | 63 | @implementation JxbPlayer 64 | 65 | - (void)dealloc { 66 | [_avItem removeObserver:self forKeyPath:@"status"]; 67 | [_avItem removeObserver:self forKeyPath:@"loadedTimeRanges"]; 68 | [[NSNotificationCenter defaultCenter]removeObserver:self]; 69 | } 70 | 71 | - (id)initWithMainColor:(UIColor*)color frame:(CGRect)frame { 72 | self = [super initWithFrame:frame]; 73 | if (self) { 74 | 75 | [[NSNotificationCenter defaultCenter] addObserver:self 76 | selector:@selector(handleInterruption:) 77 | name:AVAudioSessionInterruptionNotification 78 | object:[AVAudioSession sharedInstance]]; 79 | [[NSNotificationCenter defaultCenter] addObserver:self 80 | selector:@selector(handleInterruption:) 81 | name:AVAudioSessionRouteChangeNotification 82 | object:[AVAudioSession sharedInstance]]; 83 | 84 | _maincolor = color; 85 | [self setUI]; 86 | } 87 | return self; 88 | } 89 | 90 | - (void)setUI { 91 | UIView* vline = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 0.5)]; 92 | vline.backgroundColor = [UIColor colorWithRed:250/255. green:250/255. blue:250/255. alpha:1]; 93 | [self addSubview:vline]; 94 | 95 | _btnPlay = [[UIButton alloc] initWithFrame:CGRectMake((self.frame.size.width - playerIconWidth - 10) / 2, 0, playerIconWidth + 10, playerIconWidth + 10)]; 96 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_play"] tintColor:_maincolor] forState:UIControlStateNormal]; 97 | [_btnPlay addTarget:self action:@selector(btnPauseAction) forControlEvents:UIControlEventTouchUpInside]; 98 | [self addSubview:_btnPlay]; 99 | 100 | _btnNext = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width / 2 + playerIconWidth + 15, 5, playerIconWidth, playerIconWidth)]; 101 | [_btnNext setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_next"] tintColor:_maincolor] forState:UIControlStateNormal]; 102 | [_btnNext addTarget:self action:@selector(btnNextAction) forControlEvents:UIControlEventTouchUpInside]; 103 | [self addSubview:_btnNext]; 104 | 105 | _btnBack = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width / 2 - playerIconWidth * 2 - 15, 5, playerIconWidth, playerIconWidth)]; 106 | [_btnBack setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_back"] tintColor:_maincolor] forState:UIControlStateNormal]; 107 | [_btnBack addTarget:self action:@selector(btnBackAction) forControlEvents:UIControlEventTouchUpInside]; 108 | [self addSubview:_btnBack]; 109 | 110 | CGSize s = [@"00:00" textSizeWithFont:playerFont constrainedToSize:CGSizeMake(MAXFLOAT, 999) lineBreakMode:NSLineBreakByCharWrapping]; 111 | 112 | _lblPlayTime = [[UILabel alloc] initWithFrame:CGRectMake(20, 5 + (playerIconWidth - s.height) / 2, s.width, s.height)]; 113 | _lblPlayTime.font = playerFont; 114 | _lblPlayTime.text = @"00:00"; 115 | _lblPlayTime.textColor = _maincolor; 116 | [self addSubview:_lblPlayTime]; 117 | 118 | _lblAllTime = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width - 20 - s.width, 5 + (playerIconWidth - s.height) / 2, s.width, s.height)]; 119 | _lblAllTime.font = playerFont; 120 | _lblAllTime.text = @"00:00"; 121 | _lblAllTime.textColor = _maincolor; 122 | [self addSubview:_lblAllTime]; 123 | 124 | _slider = [[UISlider alloc] initWithFrame:CGRectMake(20, playerIconWidth + 20, self.frame.size.width - 40, 10)]; 125 | _slider.minimumValue = 0; 126 | _slider.maximumValue = 1; 127 | [_slider setMinimumTrackTintColor:_maincolor]; 128 | [_slider setMaximumTrackTintColor:[UIColor colorWithRed:200/255. green:200/255. blue:200/255. alpha:0.3]]; 129 | [_slider setThumbTintColor:_maincolor]; 130 | [_slider addTarget:self action:@selector(slideValueChanged:) forControlEvents:UIControlEventValueChanged]; 131 | [_slider addTarget:self action:@selector(sliderTouchDown:) forControlEvents:UIControlEventTouchDown]; 132 | [_slider addTarget:self action:@selector(sliderTouchUp:) forControlEvents:UIControlEventTouchUpInside]; 133 | [_slider addTarget:self action:@selector(sliderTouchUp:) forControlEvents:UIControlEventTouchUpOutside]; 134 | [self addSubview:_slider]; 135 | 136 | _vDownProgress = [[UIView alloc] initWithFrame:CGRectMake(2, 4, 0, 2)]; 137 | _vDownProgress.backgroundColor = [UIColor lightGrayColor]; 138 | _vDownProgress.layer.cornerRadius = 1; 139 | [_slider addSubview:_vDownProgress]; 140 | } 141 | 142 | - (void)stop { 143 | [_avPlayer pause]; 144 | if(_avTimer) 145 | { 146 | [_avTimer invalidate]; 147 | _avTimer = nil; 148 | } 149 | if(_delegate && [_delegate respondsToSelector:@selector(XBPlayer_stop)]) 150 | [_delegate XBPlayer_stop]; 151 | } 152 | 153 | - (void)play { 154 | if(!_itemUrl) 155 | return; 156 | NSURL * songUrl = nil; 157 | if ([_itemUrl rangeOfString:@"http:"].length > 0) 158 | songUrl = [NSURL URLWithString:_itemUrl]; 159 | else 160 | { 161 | songUrl = [[NSURL alloc] initFileURLWithPath:_itemUrl]; 162 | } 163 | AVURLAsset *movieAsset = [[AVURLAsset alloc]initWithURL:songUrl options:nil]; 164 | _avItem = [AVPlayerItem playerItemWithAsset:movieAsset]; 165 | [_avItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];// 监听status属性 166 | [_avItem addObserver:self forKeyPath:@"loadedTimeRanges" options:NSKeyValueObservingOptionNew context:nil];// 监听loadedTimeRanges属性 167 | _avPlayer = [[AVPlayer alloc] initWithPlayerItem:_avItem]; 168 | [_avPlayer play]; 169 | 170 | //loading 171 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_refresh"] tintColor:_maincolor] forState:UIControlStateNormal]; 172 | CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 173 | rotateAnimation.repeatCount = INFINITY; 174 | rotateAnimation.byValue = @(M_PI*2); 175 | rotateAnimation.duration = 1.5; 176 | [_btnPlay.layer addAnimation:rotateAnimation forKey:@"rotateAnimation"]; 177 | } 178 | 179 | - (void)playing { 180 | NSTimeInterval avDuration = [self playableDuration]; 181 | if (avDuration > 0) 182 | { 183 | _lblAllTime.text = [self convertToMM:avDuration]; 184 | 185 | NSArray* down = _avPlayer.currentItem.loadedTimeRanges; 186 | CMTimeRange range = [[down objectAtIndex:0] CMTimeRangeValue]; 187 | double download = range.duration.value / range.duration.timescale; 188 | _vDownProgress.frame = CGRectMake(2, 4, download / avDuration * _slider.frame.size.width, 2); 189 | } 190 | NSTimeInterval avPlayTime = [self playableCurrentTime]; 191 | if (!_bSliderDragging && avPlayTime > 0) 192 | { 193 | _lblPlayTime.text = [self convertToMM:avPlayTime]; 194 | } 195 | if (!_bSliderDragging && avPlayTime > 0 && avDuration > 0) 196 | { 197 | CGFloat percent = avPlayTime / avDuration; 198 | [_slider setValue:percent animated:YES]; 199 | } 200 | 201 | if(_delegate && [_delegate respondsToSelector:@selector(XBPlayer_playDuration:)]) 202 | [_delegate XBPlayer_playDuration:avPlayTime]; 203 | 204 | if (avDuration == avPlayTime) 205 | { 206 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_play"] tintColor:_maincolor] forState:UIControlStateNormal]; 207 | _bStop = YES; 208 | if(_avTimer) 209 | { 210 | [_avTimer invalidate]; 211 | _avTimer = nil; 212 | } 213 | return; 214 | } 215 | if(_avTimer) 216 | { 217 | [_avTimer invalidate]; 218 | _avTimer = nil; 219 | } 220 | _avTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(playing) userInfo:nil repeats:YES]; 221 | } 222 | 223 | - (NSString*)convertToMM:(NSTimeInterval)t { 224 | int m = t / 60; 225 | int s = (int)t % 60; 226 | NSString* mStr = [NSString stringWithFormat:(m < 10 ? @"0%d" : @"%d"),m]; 227 | NSString* sStr = [NSString stringWithFormat:(s < 10 ? @"0%d" : @"%d"),s]; 228 | return [NSString stringWithFormat:@"%@:%@",mStr,sStr]; 229 | } 230 | 231 | #pragma mark - back && next 232 | - (void)btnPauseAction { 233 | if (!_bBegin) 234 | { 235 | _bBegin = YES; 236 | [self play]; 237 | if(_delegate && [_delegate respondsToSelector:@selector(XBPlayer_play)]) 238 | [_delegate XBPlayer_play]; 239 | return; 240 | } 241 | else if (_bStop) { 242 | _bStop = NO; 243 | [_avPlayer seekToTime:CMTimeMakeWithSeconds(0, playerScale)]; 244 | [_avPlayer play]; 245 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_pause"] tintColor:_maincolor] forState:UIControlStateNormal]; 246 | return; 247 | } 248 | else if (_bPausing) { 249 | [_avPlayer play]; 250 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_pause"] tintColor:_maincolor] forState:UIControlStateNormal]; 251 | if(_avTimer) 252 | { 253 | [_avTimer invalidate]; 254 | _avTimer = nil; 255 | } 256 | _avTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(playing) userInfo:nil repeats:YES]; 257 | } 258 | else { 259 | [_avPlayer pause]; 260 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_play"] tintColor:_maincolor] forState:UIControlStateNormal]; 261 | if(_delegate && [_delegate respondsToSelector:@selector(XBPlayer_pause)]) 262 | [_delegate XBPlayer_pause]; 263 | if(_avTimer) 264 | { 265 | [_avTimer invalidate]; 266 | _avTimer = nil; 267 | } 268 | } 269 | _bPausing = !_bPausing; 270 | } 271 | 272 | - (void)btnBackAction { 273 | if (!_bLoadFinish || _bStop) 274 | return; 275 | int t = [self playableCurrentTime]; 276 | if(t >=0) 277 | { 278 | if(_avTimer) 279 | { 280 | [_avTimer invalidate]; 281 | _avTimer = nil; 282 | } 283 | _avTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(playing) userInfo:nil repeats:YES]; 284 | [_avPlayer seekToTime:CMTimeMakeWithSeconds((t-20), playerScale)]; 285 | } 286 | } 287 | 288 | - (void)btnNextAction { 289 | if (!_bLoadFinish || _bStop) 290 | return; 291 | int t = [self playableCurrentTime]; 292 | if(t >=0) 293 | { 294 | if(_avTimer) 295 | { 296 | [_avTimer invalidate]; 297 | _avTimer = nil; 298 | } 299 | _avTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(playing) userInfo:nil repeats:YES]; 300 | [_avPlayer seekToTime:CMTimeMakeWithSeconds((t+20), playerScale)]; 301 | } 302 | } 303 | 304 | #pragma mark - get AVPlayerItem info 305 | - (NSTimeInterval)playableDuration 306 | { 307 | AVPlayerItem * item = _avPlayer.currentItem; 308 | if (item.status == AVPlayerItemStatusReadyToPlay) { 309 | return CMTimeGetSeconds(_avPlayer.currentItem.duration); 310 | } 311 | else 312 | { 313 | return(CMTimeGetSeconds(kCMTimeInvalid)); 314 | } 315 | } 316 | 317 | - (NSTimeInterval)playableCurrentTime 318 | { 319 | AVPlayerItem * item = _avPlayer.currentItem; 320 | if (item.status == AVPlayerItemStatusReadyToPlay) { 321 | return CMTimeGetSeconds(_avPlayer.currentItem.currentTime); 322 | } 323 | else 324 | { 325 | return(CMTimeGetSeconds(kCMTimeInvalid)); 326 | } 327 | } 328 | 329 | #pragma mark - uislide 330 | - (void)slideValueChanged:(UISlider*)slider { 331 | NSLog(@"%f",slider.value); 332 | int t = [self playableDuration] * slider.value; 333 | if(t > 0) 334 | { 335 | _lblPlayTime.text = [self convertToMM:t]; 336 | } 337 | } 338 | 339 | - (void)sliderTouchDown:(UISlider*)slider { 340 | NSLog(@"sliderTouchDown"); 341 | _bSliderDragging = YES; 342 | } 343 | 344 | - (void)sliderTouchUp:(UISlider*)slider { 345 | NSLog(@"sliderTouchUp"); 346 | 347 | if(_avTimer) 348 | { 349 | [_avTimer invalidate]; 350 | _avTimer = nil; 351 | } 352 | 353 | int t = [self playableDuration] * slider.value; 354 | t = t < 0 ? 0 : t; 355 | [_avPlayer seekToTime:CMTimeMakeWithSeconds(t, playerScale) completionHandler:^(BOOL bFinish){ 356 | if(bFinish){ 357 | _bSliderDragging = NO; 358 | _avTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(playing) userInfo:nil repeats:YES]; 359 | } 360 | }]; 361 | } 362 | 363 | #pragma mark - observe 364 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 365 | if ([keyPath isEqualToString:@"status"]) 366 | { 367 | AVPlayerItem* item = (AVPlayerItem*)object; 368 | if (item.status == AVPlayerItemStatusReadyToPlay) { 369 | _bLoadFinish = YES; 370 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_pause"] tintColor:_maincolor] forState:UIControlStateNormal]; 371 | [_btnPlay.layer removeAllAnimations]; 372 | [self playing]; 373 | } 374 | } 375 | else if ([keyPath isEqualToString:@"loadedTimeRanges"]) 376 | { 377 | 378 | } 379 | } 380 | 381 | #pragma mark - AvAudioNotificaion 382 | - (void)handleInterruption:(NSNotification*)noti { 383 | [_btnPlay setImage:[self imageWithTintColor:[UIImage imageNamed:@"icon_play"] tintColor:_maincolor] forState:UIControlStateNormal]; 384 | if(_delegate && [_delegate respondsToSelector:@selector(XBPlayer_pause)]) 385 | [_delegate XBPlayer_pause]; 386 | _bPausing = YES; 387 | } 388 | 389 | #pragma mark - UIImage 390 | - (UIImage *)imageWithTintColor:(UIImage*)img tintColor:(UIColor *)tintColor 391 | { 392 | //We want to keep alpha, set opaque to NO; Use 0.0f for scale to use the scale factor of the device’s main screen. 393 | UIGraphicsBeginImageContextWithOptions(img.size, NO, 0.0f); 394 | [tintColor setFill]; 395 | CGRect bounds = CGRectMake(0, 0, img.size.width, img.size.height); 396 | UIRectFill(bounds); 397 | 398 | //Draw the tinted image in context 399 | [img drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f]; 400 | 401 | UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext(); 402 | UIGraphicsEndImageContext(); 403 | 404 | return tintedImage; 405 | } 406 | @end 407 | -------------------------------------------------------------------------------- /JxbPlayerControl/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JxbPlayerControl 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /JxbPlayerControl/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JxbPlayerControl 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "JxbPlayer.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | JxbPlayer* jxb = [[JxbPlayer alloc] initWithMainColor:[UIColor redColor] frame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 100)]; 22 | jxb.itemUrl = @"http://stream.51voa.com/201506/se-health-south-korea-mers-15jun15.mp3"; 23 | [self.view addSubview:jxb]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /JxbPlayerControl/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JxbPlayerControl 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JxbPlayerControlTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | net.fanwa.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /JxbPlayerControlTests/JxbPlayerControlTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JxbPlayerControlTests.m 3 | // JxbPlayerControlTests 4 | // 5 | // Created by Peter on 15/6/16. 6 | // Copyright (c) 2015年 Peter. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface JxbPlayerControlTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation JxbPlayerControlTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peter Jin 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JxbPlayerControl 2 | A Mp3 Player Control. Support ServerUrl & LocolFile 3 | 4 | #Support CocoaPods 5 | Pod 'JxbPlayerControl' 6 | 7 | #Code 8 | ``` object-c 9 | JxbPlayer* jxb = [[JxbPlayer alloc] initWithMainColor:[UIColor redColor] frame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 100)]; 10 | 11 | jxb.itemUrl = @"http://stream.51voa.com/201506/se-health-south-korea-mers-15jun15.mp3"; 12 | 13 | [self.view addSubview:jxb]; 14 | ``` 15 | 16 | #For Example 17 | ![](https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/master/screenshot.gif) 18 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JxbSir/JxbPlayerControl/80520292fb0f3e04c233eb47a19eefadcc68908d/screenshot.gif --------------------------------------------------------------------------------