Playing Videos
In this tutorial i will be showing you how to play video files in your apps
Features:
- 1 Round Rect Button
- 1 Video Files
Playing videos in your application can give so much more information than a standard pages of text take youtube for example users are able to share and express information in a way a written page cannot
ViewController.h
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController :UIViewController {
}
-(IBAction)playvideo;
@end
ViewController.m
ViewController.h
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController :UIViewController {
}
-(IBAction)playvideo;
@end
@implementation ViewController
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Video1" ofType:@"mp4"]];
pathForResource:@"Video1" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
[playercontroller release];
playercontroller = nil;
}
@end
0 ความคิดเห็น:
แสดงความคิดเห็น