我尝试了以下代码
count + = 2
if count > 100 {
soundRecorder?.stop()
if player != nil {
if player!.isPlaying {
player!.stop()
}
}
print("Recording complete")
}
soundRecorder?.updateMeters()
if !(soundRecorder?.isRecording)! {
visualizerTimer?.invalidate()
visualizerTimer = nil
}
else {
self.progressView.setProgress(visualizerTimer, animated: true) // receiving error for "Cannot convert value of type 'Timer?' to expected argument type 'Float'"
print("Recording")
}
我希望progressView应该根据录制的音频大小移动,如果音频播放1分钟,则progressView应该根据音频时间移动。 请帮助我解决这个问题。***
答案 0 :(得分:0)
尝试实现此代码,对您有帮助
let intervel = CMTime(value: 1, timescale: 2)
player?.addPeriodicTimeObserver(forInterval: intervel, queue: DispatchQueue.main, using: { (progressTime) in
let seconds = Int(CMTimeGetSeconds(progressTime))
let secondsString = String(format: "%02d", seconds % 60)
let minutesAString = String(format: "%02d", seconds / 60)
// move the slider
if let duration = self.player?.currentItem?.duration {
let durationSeconds = Int(CMTimeGetSeconds(duration))
print("value of duratioinSeconds: \(seconds))")
print("value of Seconds: \(durationSeconds)")
print(Float(seconds % durationSeconds))
self.Slider.setValue(Float(durationSeconds), animated: true)
self.Slider.minimumValue = 1
self.Slider.maximumValue = Float(durationSeconds)
self.Slider.value = Float(seconds % durationSeconds)
}
})
答案 1 :(得分:0)
如果您使用的是AVPlayer,则此代码应该对您有用,我在其中一个应用程序中使用了它。它确实需要您设置当前播放项目的持续时间。您可以使用Complete output from command python setup.py egg_info:
TypeError: 'tuple' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\TOSHIB~1\AppData\Local\Temp\pip-req-build-hztbm9lf\setup.py", line 13, in <module>
include_dirs=[numpy.get_include()])]
File "c:\python34\lib\site-packages\setuptools\__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "c:\python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "c:\python34\lib\distutils\dist.py", line 971, in run_command
log.info("running %s", command)
File "c:\python34\lib\distutils\log.py", line 44, in info
self._log(INFO, msg, args)
File "c:\python34\lib\distutils\log.py", line 33, in _log
msg = msg.encode(encoding, "backslashreplace").decode(encoding)
TypeError: encoding with 'cp1252' codec failed (TypeError: 'tuple' object is not callable)
属性来调整此方法的运行频率(这将更改progressView的更改程度)
interval