2

I have a basic login screen setup; logo, username, and password field. I had a designer make a cool animation for the logo and received it as an MP4 file.

I would like to make it so that when the user opens the app, or visits the login screen, the logo animation plays once in my view.

I was only able to find libraries to play MP4 files full screen or with a play button being triggered on the middle of the view with a close button on the top corners, similar to how you would watch a regular video on iPhone.

Anyone know how to play an embedded animation within a view just once? I could possibly ask for the animation in a different file format if theres another way.

Thanks!

2 Answers2

1

I think you can achieve this using .gif file in a better way.

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"gif"];
    UIImage *testImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
    self.dataImageView.animationImages = testImage.images;
    self.dataImageView.animationDuration = testImage.duration;
    self.dataImageView.animationRepeatCount = 1;
    self.dataImageView.image = testImage.images.lastObject;
    [self.dataImageView startAnimating];
}

.gif file would play for only once & then last frame of that file would be stable.

Hope this would help..!!!

Sneha
  • 880
  • 9
  • 24
  • Keep in mind that the method described here will crash your device if the gif is is very large in terms of W x H or is too long. See this Q for more info http://stackoverflow.com/a/17225223/763355 – MoDJ Jan 10 '16 at 23:57
1

You can use MPMoviePlayerController to play the movie. Refer to this post

iPhone SDK:How do you play video inside a view? Rather than fullscreen

Community
  • 1
  • 1
meim
  • 740
  • 4
  • 7