Animation Images
1 ) First Add Two Frameworks :
- AVFoundation.Framework
- MediaPlayer.Framework
2 ) Add Images and Two Button in Storyboard :
3 ) Write This Code In ViewController.h :
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController
{
AVAudioPlayer *audioobj;
}
@property(strong,nonatomic)IBOutlet UIImageView *imgobj;
@property(strong,nonatomic)NSMutableArray *arrobj;
- (IBAction)playvideo:(id)sender;
- (IBAction)stopvideo:(id)sender;
@end
4 ) Write This Code In ViewController.m :
@implementation ViewController
@synthesize imgobj,arrobj;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (IBAction)playvideo:(id)sender
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"mp3"];
audioobj = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioobj play];
arrobj = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"win_1.png"],
[UIImage imageNamed:@"win_2.png"],
[UIImage imageNamed:@"win_3.png"],
[UIImage imageNamed:@"win_4.png"],
[UIImage imageNamed:@"win_5.png"],
[UIImage imageNamed:@"win_6.png"],
[UIImage imageNamed:@"win_7.png"],
[UIImage imageNamed:@"win_8.png"],
[UIImage imageNamed:@"win_9.png"],
[UIImage imageNamed:@"win_10.png"],
[UIImage imageNamed:@"win_11.png"],
[UIImage imageNamed:@"win_12.png"],
[UIImage imageNamed:@"win_13.png"],
[UIImage imageNamed:@"win_14.png"],
[UIImage imageNamed:@"win_15.png"],
[UIImage imageNamed:@"win_16.png"],nil];
imgobj.animationImages = arrobj ;
imgobj.animationDuration = 1;
[imgobj startAnimating];
}
- (IBAction)stopvideo:(id)sender
{
[audioobj stop];
[imgobj stopAnimating];
}
@end
No comments:
Post a Comment