Thursday, 1 October 2015

how to work Audio Recoreder and video play from Youtube In Ios / Iphone

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


@interface ViewController : UIViewController<MFMailComposeViewControllerDelegate,MFMessageComposeViewControllerDelegate >
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;


@property (weak, nonatomic) IBOutlet UIButton *btnPlayVideo;


- (IBAction)btnPlayVideoClick:(id)sender;
- (IBAction)btnSendSMSOutSideAppClick:(id)sender;
- (IBAction)btnPlayLiveVideoClick:(id)sender;
@end


 -----------------------------use some methor Or Action on Play video and recording


- (IBAction)btnPlayVideoClick:(id)sender {

   
    //Local
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"final_video" ofType:@"mov"]];
   
    self.moviePlayer =  [[MPMoviePlayerController alloc]
                     initWithContentURL:url];
   
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_moviePlayer];
   
    self.moviePlayer.controlStyle = MPMovieControlStyleDefault;
    self.moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:self.moviePlayer.view];
    [self.moviePlayer setFullscreen:YES animated:YES];
}

- (IBAction)btnPlayLiveVideoClick:(id)sender {
   
    //Live
    NSURL *url = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
   
    self.moviePlayer =  [[MPMoviePlayerController alloc]
                         initWithContentURL:url];
   
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_moviePlayer];
   
    self.moviePlayer.controlStyle = MPMovieControlStyleDefault;
    self.moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:self.moviePlayer.view];
    [self.moviePlayer setFullscreen:YES animated:YES];
}


#pragma mark MPMoviePlayerController methods

- (void) moviePlayBackDidFinish:(NSNotification*)notification {
    MPMoviePlayerController *player = [notification object];
    [[NSNotificationCenter defaultCenter]
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:player];
   
    if ([player
         respondsToSelector:@selector(setFullscreen:animated:)])
    {
        [player.view removeFromSuperview];
    }
}