diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 77df7be..38c6d0d 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - SJAudioPlayer (1.0.3): - - SJAudioPlayer/Core (= 1.0.3) - - SJAudioPlayer/Core (1.0.3) + - SJAudioPlayer (1.0.4): + - SJAudioPlayer/Core (= 1.0.4) + - SJAudioPlayer/Core (1.0.4) DEPENDENCIES: - SJAudioPlayer (from `../`) @@ -11,7 +11,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - SJAudioPlayer: 6c9edda87247f318769cdd869ec444651d80cb44 + SJAudioPlayer: 923dbc71c3a4aa81e2b5b535c8a9c7db679e8a33 PODFILE CHECKSUM: 04ace31981e2163660b2b311309546932112e7d9 diff --git a/Example/Pods/Local Podspecs/SJAudioPlayer.podspec.json b/Example/Pods/Local Podspecs/SJAudioPlayer.podspec.json index 1e48854..287b2f1 100644 --- a/Example/Pods/Local Podspecs/SJAudioPlayer.podspec.json +++ b/Example/Pods/Local Podspecs/SJAudioPlayer.podspec.json @@ -1,6 +1,6 @@ { "name": "SJAudioPlayer", - "version": "1.0.3", + "version": "1.0.4", "summary": "iOS MP3 Audio Player using AVAudioEngine.", "description": "https://github.com/changsanjiang/SJAudioPlayer/blob/master/README.md", "homepage": "https://github.com/changsanjiang/SJAudioPlayer", @@ -13,7 +13,7 @@ }, "source": { "git": "https://github.com/changsanjiang/SJAudioPlayer.git", - "tag": "1.0.3" + "tag": "1.0.4" }, "platforms": { "ios": "9.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 77df7be..38c6d0d 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,7 +1,7 @@ PODS: - - SJAudioPlayer (1.0.3): - - SJAudioPlayer/Core (= 1.0.3) - - SJAudioPlayer/Core (1.0.3) + - SJAudioPlayer (1.0.4): + - SJAudioPlayer/Core (= 1.0.4) + - SJAudioPlayer/Core (1.0.4) DEPENDENCIES: - SJAudioPlayer (from `../`) @@ -11,7 +11,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - SJAudioPlayer: 6c9edda87247f318769cdd869ec444651d80cb44 + SJAudioPlayer: 923dbc71c3a4aa81e2b5b535c8a9c7db679e8a33 PODFILE CHECKSUM: 04ace31981e2163660b2b311309546932112e7d9 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 880ffe9..cc7fbe0 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -466,8 +466,8 @@ BFDFE7DC352907FC980B868725387E98 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1240; - LastUpgradeCheck = 1240; + LastSwiftUpdateCheck = 1300; + LastUpgradeCheck = 1300; }; buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; diff --git a/Example/SJAudioPlayer.xcodeproj/project.pbxproj b/Example/SJAudioPlayer.xcodeproj/project.pbxproj index 063a7c6..8f09ffc 100644 --- a/Example/SJAudioPlayer.xcodeproj/project.pbxproj +++ b/Example/SJAudioPlayer.xcodeproj/project.pbxproj @@ -41,7 +41,6 @@ 77EF40D1262E802A00A985A1 /* 网易游戏 - 长寿村.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 77EF40D0262E802A00A985A1 /* 网易游戏 - 长寿村.mp3 */; }; 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 89140F21B5BF792C68A94690 /* libPods-SJAudioPlayer_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 54ABA5E259837B9C90EF7C7A /* libPods-SJAudioPlayer_Tests.a */; }; - A6A1D5A928AF2882009CDFDD /* 1.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = A6A1D5A828AF2882009CDFDD /* 1.mp3 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -120,7 +119,6 @@ 77EF40D0262E802A00A985A1 /* 网易游戏 - 长寿村.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "网易游戏 - 长寿村.mp3"; sourceTree = ""; }; 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; A458E1DB0F5A924DAA4692A3 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; - A6A1D5A828AF2882009CDFDD /* 1.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = 1.mp3; sourceTree = ""; }; C5F4F3A367A6D5A00D051C10 /* SJAudioPlayer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SJAudioPlayer.podspec; path = ../SJAudioPlayer.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; /* End PBXFileReference section */ @@ -193,7 +191,6 @@ 6003F5A5195388D20070C39A /* SJViewController.h */, 6003F5A6195388D20070C39A /* SJViewController.m */, 77EF40D0262E802A00A985A1 /* 网易游戏 - 长寿村.mp3 */, - A6A1D5A828AF2882009CDFDD /* 1.mp3 */, 77EF407B262DA10000A985A1 /* SJProgressView */, 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, 6003F5A8195388D20070C39A /* Images.xcassets */, @@ -400,7 +397,6 @@ 77EF40D1262E802A00A985A1 /* 网易游戏 - 长寿村.mp3 in Resources */, 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */, - A6A1D5A928AF2882009CDFDD /* 1.mp3 in Resources */, 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, 77EF40A2262DA10000A985A1 /* LICENSE in Resources */, diff --git a/Example/SJAudioPlayer/1.mp3 b/Example/SJAudioPlayer/1.mp3 deleted file mode 100644 index 8c42f8a..0000000 Binary files a/Example/SJAudioPlayer/1.mp3 and /dev/null differ diff --git a/Example/SJAudioPlayer/SJViewController.m b/Example/SJAudioPlayer/SJViewController.m index 384ba65..408a316 100644 --- a/Example/SJAudioPlayer/SJViewController.m +++ b/Example/SJAudioPlayer/SJViewController.m @@ -135,7 +135,7 @@ - (IBAction)playOrPause:(UIButton *)sender { - (IBAction)replace { NSURL *URL = nil; - URL = [NSBundle.mainBundle URLForResource:@"1" withExtension:@"mp3"]; + URL = [NSBundle.mainBundle URLForResource:@"网易游戏 - 长寿村" withExtension:@"mp3"]; [_player replaceAudioWithURL:URL]; [_player play]; } diff --git a/SJAudioPlayer.podspec b/SJAudioPlayer.podspec index eb6d837..d57c6ad 100644 --- a/SJAudioPlayer.podspec +++ b/SJAudioPlayer.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SJAudioPlayer' - s.version = '1.0.4' + s.version = '1.0.5' s.summary = 'iOS MP3 Audio Player using AVAudioEngine.' # This description is used to generate tags and improve search results. diff --git a/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter.m b/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter.m index 5372766..c1a72ac 100644 --- a/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter.m +++ b/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter.m @@ -102,7 +102,8 @@ - (nullable AVAudioPCMBuffer *)convertPackets:(NSArray> } } - AVAudioFrameCount nAllFrames = (AVAudioFrameCount)(_streamFormat.streamDescription->mFramesPerPacket * packets.count); + Float64 sampleRateScaleFactor = (Float64)_outputFormat.streamDescription->mSampleRate / _streamFormat.streamDescription->mSampleRate; + AVAudioFrameCount nAllFrames = (AVAudioFrameCount)(_streamFormat.streamDescription->mFramesPerPacket * packets.count * sampleRateScaleFactor); UInt32 nAllPackets = (AVAudioPacketCount)(nAllFrames / _outputFormat.streamDescription->mFramesPerPacket); AVAudioPCMBuffer *buffer = [AVAudioPCMBuffer.alloc initWithPCMFormat:_outputFormat frameCapacity:nAllFrames]; if ( buffer == nil ) { diff --git a/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter_iOS_16_Later.m b/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter_iOS_16_Later.m index 6221689..a5eb5df 100644 --- a/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter_iOS_16_Later.m +++ b/SJAudioPlayer/Core/Item/Core/Converter/APAudioContentConverter_iOS_16_Later.m @@ -24,7 +24,8 @@ - (instancetype)initWithStreamFormat:(AVAudioFormat *)streamFormat { - (nullable AVAudioPCMBuffer *)convertPackets:(NSArray> *)packets error:(NSError **)error { NSError *innerError = nil; - AVAudioFrameCount frameCapacity = (AVAudioFrameCount)(_streamFormat.streamDescription->mFramesPerPacket * packets.count); + Float64 sampleRateScaleFactor = (Float64)_outputFormat.streamDescription->mSampleRate / _streamFormat.streamDescription->mSampleRate; + AVAudioFrameCount frameCapacity = (AVAudioFrameCount)(_streamFormat.streamDescription->mFramesPerPacket * packets.count * sampleRateScaleFactor); AVAudioPCMBuffer *outputBuffer = [AVAudioPCMBuffer.alloc initWithPCMFormat:_outputFormat frameCapacity:frameCapacity]; outputBuffer.frameLength = frameCapacity; __weak typeof(self) _self = self;