=> Here First Use Importing MediaPlayed:
=> Uisng MPMoviePlayerController:-
#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
==> Used Method Or Action For Play And Recording:
==> This Method For PlayingVidio:
- (IBAction)btnPlayVideoClick:(id)sender {
//==> Using Local NSBunndle Resourced Used File Path:
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];
}
==> This Method And Action For Play LIve YouTube Video On Application:
- (IBAction)btnPlayLiveVideoClick:(id)sender {
//=> Live Playing Url:-
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];
}
==> Here Use Some MpMoviewPlayed Controller Method And Action Of It:
#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];
}
}
=> Uisng MPMoviePlayerController:-
#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
==> Used Method Or Action For Play And Recording:
==> This Method For PlayingVidio:
- (IBAction)btnPlayVideoClick:(id)sender {
//==> Using Local NSBunndle Resourced Used File Path:
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];
}
==> This Method And Action For Play LIve YouTube Video On Application:
- (IBAction)btnPlayLiveVideoClick:(id)sender {
//=> Live Playing Url:-
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];
}
==> Here Use Some MpMoviewPlayed Controller Method And Action Of It:
#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];
}
}