【发布时间】:2016-05-30 12:06:46
【问题描述】:
我正在尝试显示带有视频的启动画面。为此,我有两个查询:
- 我创建了启动画面视图控制器并在应用程序启动时加载它。但是在我的初始屏幕 VC 显示任何修复之前,白屏会显示几秒钟?
-
我正在播放的视频仅显示黑屏。我猜不出我做错了什么。下面是它的代码。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) let vc = SplashScreenVC(nibName: "SplashScreenVC", bundle: nil) let rootViewController = UINavigationController(rootViewController: vc) self.window?.rootViewController = rootViewController self.navigationController?.navigationBarHidden = true self.window?.makeKeyAndVisible() // Override point for customization after application launch. return true}
class SplashScreenVC: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.navigationController?.navigationBarHidden = true playVideo() } func playVideo() { let moviePath = NSBundle.mainBundle().pathForResource("animationVideo", ofType: "mp4") let movieUrl = NSURL.fileURLWithPath(moviePath!) let moviePlayer : MPMoviePlayerController = MPMoviePlayerController(contentURL: movieUrl) moviePlayer.prepareToPlay() let vV = self.view.viewWithTag(SplashScreenUITags.videoView.rawValue)! as UIView moviePlayer.controlStyle = MPMovieControlStyle.None moviePlayer.scalingMode = MPMovieScalingMode.Fill moviePlayer.movieSourceType = MPMovieSourceType.File; moviePlayer.view.frame = vV.bounds vV.addSubview(moviePlayer.view) moviePlayer.play() NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("moviePlayBackDidFinish:"), name: MPMoviePlayerPlaybackDidFinishNotification, object: moviePlayer) } }
【问题讨论】:
标签: ios iphone mpmovieplayercontroller splash-screen