Saturday, December 9, 2023
HomeiOS Developmentios - How you can get timestamp of a video in Swift...

ios – How you can get timestamp of a video in Swift when tapping on display screen?


I am attempting to fill a textbox with the timestamp of a video I added to my view utilizing AVPlayer. Mainly everytime I faucet the display screen I need the textbox to be stuffed with the timestamp of the video in the intervening time of taping. Here is the code I wrote thus far.

import UIKit
import AVKit
import AVFoundation

class Screen2: UIViewController {

@IBOutlet var textBoxContent2: UITextField!
let participant = AVPlayer(url: URL(fileURLWithPath: Bundle.important.path(forResource: "video", ofType: "mp4")!))

override func viewDidLoad() {
    tremendous.viewDidLoad()
    textBoxContent2.isUserInteractionEnabled = false
    // Do any further setup after loading the view.
    
}

override func viewDidAppear(_ animated: Bool) {
    tremendous.viewDidAppear(animated)
    
    let layer = AVPlayerLayer(participant: participant)
    layer.body = view.bounds
    view.layer.addSublayer(layer)
    
    participant.play()
}

@IBAction func didTapView(_ sender: UITapGestureRecognizer) {

}

@IBAction func stopVideo(_ sender: UITapGestureRecognizer) {
    participant.pause()
}

@IBAction func startVideo(_ sender: UITapGestureRecognizer) {
    participant.play()
}

}

I need the strategy didTapView() to do what I requested above. Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments