0

Video as launch screen in IOS Objective C. Any help appreciated.

  • 3
    simple, initialy create the thumbnail (add video thumb)and add into launch screen, after that loadvideo in anothercontoller (set video controller as ur inital controller)and navigate to anywhere – Anbu.Karthik Feb 01 '17 at 06:55
  • @Anbu.Karthik , Your Answer is not match my requirement, Below explaination of Mr.Abdu match nicely my requirement. Anyway thanks for your quick reply. – Neelaganda Moorthy Feb 01 '17 at 07:21

1 Answers1

3

Moorthy You can use AVPlayer and AVPlayerViewController help for Achieving this.

I will Explain you in detail the process of doing this trick.

Step One Add following framework in your Xcode project and import them in on your Appdelegate.

  1. @import AVFoundation;
  2. @import AVKit;
  3. @import UIKit;

Step Two Add following piece of code in your Appdelegate didFinishLaunchingWithOptions Method

    // grab a local URL to our video
        NSURL *videoURL = [[NSBundle mainBundle]URLForResource:@"myvideo" withExtension:@"mov"];

        // create an AVPlayer
        AVPlayer *player = [AVPlayer playerWithURL:videoURL];

        // create a player view controller
        AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
        controller.player = player;
        controller.showsPlaybackControls = false;
        controller.view.frame = self.window.frame;
        controller.modalPresentationStyle = UIModalPresentationFullScreen;
        self.window.rootViewController = controller;
        [player play];

// Adding Observer for your video file,
        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
        [notificationCenter addObserver:self selector:@selector(videoDidFinish:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];

Step Three

After Video Completion you will be take into this place

- (void)videoDidFinish:(id)notification {   

AVPlayerItem *p = [notification object];
        //do something with player if you want

 //Remove Observer  
[[NSNotificationCenter defaultCenter] removeObserver:self];     

//your initial view can proceed from here 
[self ProccedToYourViewController];
}

Some Tips

You can smoothly stop your video play by adding fade in and fade out animation, I will show you how i did for myself

//AvplayerViewController View(Video View).
[self.controller.view setAlpha:1.0f];
        [UIView animateWithDuration:2.0f animations:^{
//AvplayerViewController View(Video View) setting to hide.
            [self.controller.view setAlpha:0.0f];
//initialview(Your Initial View) that add as window root now
            self.window.rootViewController  = initialview;
            [initialview.view setAlpha:1.0f];
            [self.window makeKeyAndVisible];
} completion:nil];

Now You are ready to go. Cheers

Abdul Nasir B A
  • 1,077
  • 2
  • 8
  • 25