0

画面から指を離さずに長押しジェスチャを終了しようとしています。それは迅速に可能ですか?

動画を撮影できるアプリを作っています。ボタンを押すと録画が開始され、画面から指を離すと録画が終了します。その部分は完璧に機能します。また、ボタンを指で押したままにしておくと、長押しジェスチャが 30 秒後に終了することも必要です。実際に録音を停止するようにしましたが、問題は、録音が停止したときに長押しジェスチャーが実際に終了しないことです。

これが私のコードの一部です:

func stop() {
    let seconds : Int64 = 5
    let preferredTimeScale : Int32 = 1
    let maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
    movieOutput.maxRecordedDuration = maxDuration

    if movieOutput.recordedDuration == movieOutput.maxRecordedDuration {
       movieOutput.stopRecording()
    }
}

func longTap(_ sender: UILongPressGestureRecognizer){
    print("Long tap")

    stop()

    if sender.state == .ended {
        print("end end")
        movieOutput.stopRecording()
    }
    else if sender.state == .began {
        print("begin")
        captureSession.startRunning()
        startRecording()
    }
}
4

1 に答える 1