HomeiOS Developmentios - find out how to create a VAST url preroll for...

ios – find out how to create a VAST url preroll for my xcode tvos video participant?


I am new to Xcode growth, I must make a video participant that performs a preroll primarily based on an enormous tag url.

I attempted trying on-line all over the place however have not discovered something useful. Im utilizing Swift & Storyboard.

that is my code now:

import UIKit
import AVKit
import AVFoundation


class ViewController: UIViewController {
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any further setup after loading the view.
    }
    
    @IBAction func playVideoButton(_ sender: Any) {
        playVideo()
    }
    override func viewDidAppear(_ animated: Bool) {
        tremendous.viewDidAppear(animated)
    }
    
    personal func displayWhatButtonPressed(buttonText: String, xPosition: Int ,yPosition: Int) {
            let label = UILabel(body: CGRect(x: xPosition, y: yPosition, width: 850, top: 40))
            label.textual content = buttonText
            view.addSubview(label)
            
            let timer = Timer.scheduledTimer(withTimeInterval: 3, repeats: false) { timer in
                // Cover the label
                label.removeFromSuperview()
            }
        }

    
    personal func playVideo() {
        displayWhatButtonPressed(buttonText: "Enjoying Video",xPosition: 1500, yPosition: 1020)
        guard let path = Bundle.fundamental.path(forResource: "video1920x1080", ofType: "mp4") else {
            debugPrint("not discovered")
            return
        }

        let participant = AVPlayer(url: URL(fileURLWithPath: path))
        let playerController = AVPlayerViewController()
        playerController.participant = participant
        
        // Set the video participant's body to the specified place and dimension
        let videoFrame = CGRect(x: 150, y: view.bounds.top/2 - 250 , width: 1080, top: 720)
        playerController.view.body = videoFrame
        
        addChild(playerController)
        view.addSubview(playerController.view)
        
        participant.play()
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments