Audio,Video And Animation





VC.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
- (IBAction)playBtn:(id)sender;
- (IBAction)stopBtn:(id)sender;

@property NSMutableArray *arrayImages;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

- (IBAction)sliderForDuration:(id)sender;
@property (weak, nonatomic) IBOutlet UISlider *sliderDuration;


@end

VC.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    UITabBarItem *tabBarItem0 = [self.tabBarController.tabBar.items objectAtIndex:0];
//    UITabBarItem *tabBarItem1 = [self.tabBarController.tabBar.items objectAtIndex:1];
//     UITabBarItem *tabBarItem2 = [self.tabBarController.tabBar.items objectAtIndex:2];
//    
//    [tabBarItem0 setImage:[[UIImage imageNamed:@"cat.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//    [tabBarItem1 setImage:[[UIImage imageNamed:@"images.jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//    [tabBarItem2 setImage:[[UIImage imageNamed:@"images (1).jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

       self.arrayImages=[[NSMutableArray alloc]init];
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSMutableArray*)tomImages:(NSString*)imageName
                           : (int)numberOfImages
{
    for(int i = 0;i<9 ; i++)
    {
        NSString *img = [NSString stringWithFormat:@"%@000%i.png",imageName,i];
        
        [self.arrayImages addObject:[UIImage imageNamed:img]];
    }
    
    for(int j = 10 ; j < numberOfImages ; j++ )
    {
        NSString *img = [NSString stringWithFormat:@"%@00%i.png",imageName,j];
        [self.arrayImages addObject:[UIImage imageNamed:img]];
        
    }
    
    return self.arrayImages;
}


- (IBAction)playBtn:(id)sender {
    self.arrayImages  = [self tomImages:@"cat_drink":80];
    //        NSLog(@"%@",finalImgArray);
    NSLog(@"%@",self.arrayImages);
    self.imageView.animationImages=[[NSArray alloc]initWithArray:self.arrayImages ];
    [self.imageView  startAnimating];
    

}

- (IBAction)stopBtn:(id)sender {
    [self.imageView stopAnimating];
}
- (IBAction)sliderForDuration:(id)sender {
    self.imageView.animationDuration=self.sliderDuration.value;
    [self.imageView startAnimating];

}
@end

animation1.h
#import <UIKit/UIKit.h>

@interface Animation1ViewController : UIViewController
- (IBAction)playBtn:(id)sender;
- (IBAction)stopBtn:(id)sender;
@property NSMutableArray *arrayImages;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)sliderForDuration:(id)sender;
@property (weak, nonatomic) IBOutlet UISlider *sliderDuration;

@end

animation1.m

#import "Animation1ViewController.h"

@implementation Animation1ViewController
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.arrayImages=[[NSMutableArray alloc]init];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

-(NSMutableArray*)tomImages:(NSString*)imageName
                           : (int)numberOfImages
{
    for(int i = 0;i<9 ; i++)
    {
        NSString *img = [NSString stringWithFormat:@"%@000%i.png",imageName,i];
        
        [self.arrayImages addObject:[UIImage imageNamed:img]];
    }
    
    for(int j = 10 ; j < numberOfImages ; j++ )
    {
        NSString *img = [NSString stringWithFormat:@"%@00%i.png",imageName,j];
        [self.arrayImages addObject:[UIImage imageNamed:img]];
        
    }
    
    return self.arrayImages;
}



- (IBAction)playBtn:(id)sender {
    self.arrayImages  = [self tomImages:@"cat_foot_left":29];
    //        NSLog(@"%@",finalImgArray);
    NSLog(@"%@",self.arrayImages);
    self.imageView.animationImages=[[NSArray alloc]initWithArray:self.arrayImages ];
    [self.imageView  startAnimating];
    

}

- (IBAction)stopBtn:(id)sender {
    [self.imageView stopAnimating];
}
- (IBAction)sliderForDuration:(id)sender {
    self.imageView.animationDuration=self.sliderDuration.value;
    [self.imageView startAnimating];

}
@end

animation2.h

#import <UIKit/UIKit.h>

@interface Animation2View : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property NSMutableArray *arrayImages;
- (IBAction)playBtn:(id)sender;
- (IBAction)stopBtn:(id)sender;

@property (weak, nonatomic) IBOutlet UISlider *sliderDuration;
- (IBAction)sliderForDuration:(id)sender;
@end

animation2.m

#import "Animation2View.h"

@implementation Animation2View
- (void)viewDidLoad {
    [super viewDidLoad];
    self.arrayImages=[[NSMutableArray alloc]init];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSMutableArray*)tomImages:(NSString*)imageName
                           : (int)numberOfImages
{
    for(int i = 0;i<9 ; i++)
    {
        NSString *img = [NSString stringWithFormat:@"%@000%i.png",imageName,i];
        
        [self.arrayImages addObject:[UIImage imageNamed:img]];
    }
    
    for(int j = 10 ; j < numberOfImages ; j++ )
    {
        NSString *img = [NSString stringWithFormat:@"%@00%i.png",imageName,j];
        [self.arrayImages addObject:[UIImage imageNamed:img]];
        
    }
    
    return self.arrayImages;
}



- (IBAction)playBtn:(id)sender {
    self.arrayImages  = [self tomImages:@"cat_pie":22];
    //        NSLog(@"%@",finalImgArray);
    NSLog(@"%@",self.arrayImages);
    self.imageView.animationImages=[[NSArray alloc]initWithArray:self.arrayImages ];
    [self.imageView  startAnimating];

}

- (IBAction)stopBtn:(id)sender {
    [self.imageView stopAnimating];
}
- (IBAction)sliderForDuration:(id)sender {
    self.imageView.animationDuration=self.sliderDuration.value;
    [self.imageView startAnimating];

}
@end

animation3.h

#import <UIKit/UIKit.h>

@interface Animation3View : UIViewController
- (IBAction)playBtn:(id)sender;
- (IBAction)stopBtn:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property NSMutableArray *arrayImages;

@property (weak, nonatomic) IBOutlet UISlider *sliderDuration;
- (IBAction)sliderForDuration:(id)sender;

@end

animation3.m

#import "Animation3View.h"

@implementation Animation3View
- (void)viewDidLoad {
    [super viewDidLoad];
    self.arrayImages=[[NSMutableArray alloc]init];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSMutableArray*)tomImages:(NSString*)imageName
                           : (int)numberOfImages
{
    for(int i = 0;i<9 ; i++)
    {
        NSString *img = [NSString stringWithFormat:@"%@000%i.png",imageName,i];
        
        [self.arrayImages addObject:[UIImage imageNamed:img]];
    }
    
    for(int j = 10 ; j < numberOfImages ; j++ )
    {
        NSString *img = [NSString stringWithFormat:@"%@00%i.png",imageName,j];
        [self.arrayImages addObject:[UIImage imageNamed:img]];
        
    }
    
    return self.arrayImages;
}





- (IBAction)playBtn:(id)sender {
    self.arrayImages  = [self tomImages:@"cat_stomach":33];
    //        NSLog(@"%@",finalImgArray);
    NSLog(@"%@",self.arrayImages);
    self.imageView.animationImages=[[NSArray alloc]initWithArray:self.arrayImages ];
    [self.imageView  startAnimating];

}

- (IBAction)stopBtn:(id)sender {
    [self.imageView stopAnimating];
}
- (IBAction)sliderForDuration:(id)sender {
    self.imageView.animationDuration=self.sliderDuration.value;
    [self.imageView startAnimating];

}
@end

audio.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>

@interface Audio1 : UIViewController<AVAudioPlayerDelegate>
- (IBAction)venkySongsBtn:(id)sender;
@property AVPlayer *avPlayer;
@property AVAudioPlayer *player;
- (IBAction)sliderVolume:(id)sender;
@property (weak, nonatomic) IBOutlet UISlider *sliderVolumeChange;
@property (weak, nonatomic) IBOutlet UIButton *audioPlay;


- (IBAction)volumeBtn:(id)sender;


- (IBAction)nextBtn:(id)sender;

- (IBAction)progressSlider:(id)sender;


@property (weak, nonatomic) IBOutlet UISlider *sliderProgress;
-(NSString *) stringFromInterval:(NSTimeInterval)interval;



@property (weak, nonatomic) IBOutlet UILabel *time1;
@property (weak, nonatomic) IBOutlet UILabel *time2;
@property NSTimer *timer;



-(void)updateSlider;
@end

audio.m

#import "Audio1.h"

@implementation Audio1
- (void)viewDidLoad {
    [super viewDidLoad];
 }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSString *) stringFromInterval:(NSTimeInterval)interval
{
    NSInteger ti =(NSInteger)interval;
    
    int second = ti%60;
    int minute =(ti/60)%60;
    
    if (ti<=3600) {
        return [NSString stringWithFormat:@"%2d:%2d",minute,second];
    }
    else{
        return [NSString stringWithFormat:@"%02d:%02d",minute,second];
        }
    }

-(void)updateSlider{
    self.sliderProgress.value=self.player.currentTime;
    self.time1.text=[self stringFromInterval:self.player.currentTime];
}



- (IBAction)venkySongsBtn:(id)sender {
    
    NSString *obj=[[NSBundle mainBundle]pathForResource:@"05 - Raaka Raaka" ofType:@"mp3"];
    
    self.player=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:obj] error:nil];
    
    
    self.player.delegate=self;
    self.sliderProgress.value=0.0;
    
    self.time2.text=[self stringFromInterval:self.player.duration];

    
    
    if (!(self.player.playing)) {
        self.sliderProgress.maximumValue=self.player.duration;
        self.timer=[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES];
        
        [self.sliderProgress addTarget:self action:@selector(progressSlider:) forControlEvents:UIControlEventValueChanged];
               [self.player play ];
             }
    else if (self.player.playing){
        [self.player pause ];
        
    }
}
 - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
    
 [self.player pause];
}


- (IBAction)sliderVolume:(id)sender {
     self.player.volume=self.sliderVolumeChange.value;

}
 - (IBAction)volumeBtn:(id)sender {
    self.sliderVolumeChange.hidden=NO;
}

- (IBAction)nextBtn:(id)sender {
    [self.player pause];
     self.sliderVolumeChange.hidden=YES ;
    self.sliderProgress.value=0.0;
     
}

- (IBAction)progressSlider:(id)sender {
    
    [self.player setCurrentTime:self.sliderProgress.value];
   [self.player play];
}
 @end

video.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
@interface Video1 : UIViewController
@property AVPlayer *avPlayer;
- (IBAction)janathaGarageTeaserBtn:(id)sender;

@end


#import "Video1.h"

@implementation Video1
- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)janathaGarageTeaserBtn:(id)sender {
    NSString * videoFilePath = [[NSBundle mainBundle]pathForResource:@"Janatha Garage Telugu Movie Teaser - Jr NTR - Samantha - Mohanlal - Nithya Menen - Koratala Siva" ofType:@"mp4"];
    
    self.avPlayer = [AVPlayer playerWithURL:[NSURL fileURLWithPath:videoFilePath]];
    AVPlayerViewController * avplayerViewController = [[AVPlayerViewController alloc]init];
    avplayerViewController.player = self.avPlayer;
    
    
    [self.avPlayer play];
    [self presentViewController:avplayerViewController animated:YES completion:nil];
}
@end
Previous
Next Post »