Avanimator Mvid Conversion

APNG inside iOS app

I just released a framework to load and display APNG files for iOS.

You could just load an APNG image with the same pattern of UIImage and UIImageView like this by using it:

let image = APNGImage(name: "your_apng_image")
let imageView = APNGImageView(image: image)

imageView.startAnimating()

view.addSubview(imageView)

For more information, you can find it here: https://github.com/onevcat/APNGKit

Loading GIFs in iOS

The UIImageView class provides the easiest way for developers to implement animations. All you need to do is to create an UIImageView object with a series of images for animating.

Example

// Load images
NSArray *imageNames = @[@"win_1.png", @"win_2.png", @"win_3.png"];

NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i = 0; i < imageNames.count; i++) {
[images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}

// Normal Animation
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
animationImageView.animationImages = images;
animationImageView.animationDuration = 0.5;

[self.view addSubview:animationImageView];
[animationImageView startAnimating];

Load two AVPlayers with one video

It is very simple:

Init the first player:

AVAsset *asset = [AVAsset assetWithURL:URL];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];

And the second player in the same way, BUT, use the same asset from the first one.
I have verified, it works.

There is all the info you need on the Apple page:
https://developer.apple.com/library/mac/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html

This abstraction means that you can play a given asset using different
players simultaneously

this quote is from this page.



Related Topics



Leave a reply



Submit