วันพุธที่ 21 พฤศจิกายน พ.ศ. 2555

XCode 4 Tutorial Playing Videos



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

@implementation ViewController
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
    pathForResource:@"Video1" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
    initWithContentURL:url];
    [self presentMoviePlayerViewControllerAnimated:playercontroller];
    playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    [playercontroller.moviePlayer play];
    [playercontroller release];
    playercontroller = nil;
}
@end

0 ความคิดเห็น:

แสดงความคิดเห็น