设置曲目ID

当我为我的audioMix设置input参数时,我无法设置曲目ID。 我如何设置trackId? 我也试过这种方法也params.trackID(track2.trackID),但是这给了我这个错误CMPersistantTrackID -> $T4 is not identical to CMPersistantTrackID 。 我试图翻译这一行[audioInputParams setTrackID:[track trackID]]; 从https://developer.apple.com/library/ios/qa/qa1716/_index.html

错误当我运行下面的代码:

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM trackID]: unrecognized selector sent to instance 0x7f98c34cbfc0' 

码:

  let type = AVMediaTypeAudio let asset1 = AVURLAsset(URL: beatLocationURL, options: nil) let arr2 = asset1.tracksWithMediaType(type) let track2 = arr2.last as AVAssetTrack let asset = AVURLAsset(URL: vocalURL, options:nil) let arr3 = asset.tracksWithMediaType(type) let track3 = arr3.last as AVAssetTrack var trackParams = NSMutableArray() let params = AVMutableAudioMixInputParameters(track:track2) params.setVolume(0.0, atTime:kCMTimeZero) params.trackID = track2.trackID <--- this line trackParams.addObject(params) let params1 = AVMutableAudioMixInputParameters(track:track3) params1.setVolume(1.0, atTime: kCMTimeZero) params1.trackID = track3.trackID <-- this line also trackParams.addObject(params1) let mix = AVMutableAudioMix() mix.inputParameters = [trackParams]