SWIFT 3.0
你不能這樣做,在默認的啓動畫面,但你可以做一些變通方法,以達致這。
首先你應該把你的視頻的第一幀,這將是圖像。
你可以使用Photoshop或任何其他圖形工具。
現在,您可以將它設置爲UIImageView中的默認啓動畫面。
現在製作一個UIViewController並啓動它作爲初始視圖控制器。
並在下面的代碼,以播放視頻
private func playFullScreenVideo() {
// drag your video file in project
// check if video file is available,if not return
guard let path = Bundle.main.path(forResource: "video", ofType:"mp4") else {
debugPrint("video.mp4 missing")
return
}
// create instance of videoPlayer with video path
let videoPlayer = AVPlayer(url: URL(fileURLWithPath: path))
// create instance of playerlayer with videoPlayer
let playerLayer = AVPlayerLayer(player: videoPlayer)
// set its videoGravity to AVLayerVideoGravityResizeAspectFill to make it full size
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
// add it to your view
playerLayer.frame = self.view.frame
playerView.layer.addSublayer(playerLayer)
// start playing video
videoPlayer?.play()
}
讓我知道如果有這個
的可能的複製[如何發揮IOS視頻飛濺(目標C) ](https://stackoverflow.com/questions/32515407/how-to-play-a-video-splash-in-iosobjective-c) –
它在客觀上c – Jan
@Ahhishek該鏈接是ObjC,而且接受的答案是基本上連接到一個Github repo ... –