2017-08-25 1 views

Répondre

5

Vous pouvez utiliser AVPlayer

import UIKit 
import AVFoundation 
import AVKit 

class ViewController: UIViewController { 

    var avPlayer: AVPlayer! 

    override func viewDidLoad() { 

     super.viewDidLoad() 
     let filepath: String? = Bundle.main.path(forResource: "qidong", ofType: "mp4") 
     let fileURL = URL.init(fileURLWithPath: filepath!) 


     avPlayer = AVPlayer(url: fileURL) 


     let avPlayerController = AVPlayerViewController() 
     avPlayerController.player = avPlayer 
     avPlayerController.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height) 

// hide show control 
     avPlayerController.showsPlaybackControls = false 
// play video 

     avPlayerController.player?.play() 
     self.view.addSubview(avPlayerController.view) 
    } 
} 
+0

Désolé, mais je veux jouer la vidéo dans un UIView – Hamza

+0

qui est appelé « vidview » » – Hamza

+0

je veux jouer sans contrôle – Hamza