我在为audioMix设置输入参数时遇到设置曲目ID的问题。我如何设置trackId?我也尝试过这种方式params.trackID(track2.trackID),但这给了我这个错误CMPersistantTrackID -> $T4 is not identical to CMPersistantTrackID
。我正在尝试从https://developer.apple.com/library/ios/qa/qa1716/_index.html
[audioInputParams setTrackID:[track trackID]];
错误当我运行以下代码时:
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]