|
|
|
|
@ -28,23 +28,23 @@ import AVFoundation |
|
|
|
|
self._player = try AVAudioPlayer(contentsOf: url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func restore(for playDate: Date, repeatCount: Int) throws { |
|
|
|
|
func restore(for playDate: Date) throws { |
|
|
|
|
let timeLeft = playDate.timeIntervalSinceNow |
|
|
|
|
try self._play(in: timeLeft, repeatCount: repeatCount) |
|
|
|
|
try self._play(in: timeLeft) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func start(in duration: TimeInterval, repeatCount: Int) throws { |
|
|
|
|
try self._play(in: duration, repeatCount: repeatCount) |
|
|
|
|
func start(in duration: TimeInterval) throws { |
|
|
|
|
try self._play(in: duration) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _play(in duration: TimeInterval, repeatCount: Int) throws { |
|
|
|
|
fileprivate func _play(in duration: TimeInterval) throws { |
|
|
|
|
|
|
|
|
|
Conductor.maestro.activateAudioSession() |
|
|
|
|
|
|
|
|
|
self._player.prepareToPlay() |
|
|
|
|
self._player.volume = 1.0 |
|
|
|
|
self._player.delegate = self |
|
|
|
|
self._player.numberOfLoops = repeatCount |
|
|
|
|
// self._player.numberOfLoops = repeatCount |
|
|
|
|
|
|
|
|
|
Logger.log("self._player.deviceCurrentTime = \(self._player.deviceCurrentTime)") |
|
|
|
|
let time: TimeInterval = self._player.deviceCurrentTime + duration |
|
|
|
|
|