I. Include header files #import <MediaPlayer/MediaPlayer.h>
Two. Focus: Set frame to MPMoviePlayerController view and add view to a view
1 #import "ViewController.h"2 #import<MediaPlayer/MediaPlayer.h>3 4 @interfaceViewcontroller ()5 6 /*player*/7@property (nonatomic, strong) MPMoviePlayerController *player;8-(ibaction) play;9 Ten @end One A @implementationViewcontroller - -- (void) Viewdidload { the [Super Viewdidload]; - } - --(MPMoviePlayerController *) Player + { - if(_player = =Nil) { +Nsurl *url = [Nsurl urlwithstring:@"Http://v1.mukewang.com/19954d8f-e2c2-4c0a-b8c1-a4c826b5ca8b/L.mp4"]; A at_player =[[MPMoviePlayerController alloc] initwithcontenturl:url]; - - //set the Controller view location -_player.view.frame = CGRectMake (0,0, Self.view.bounds.size.width, Self.view.bounds.size.width *9/ -); - - //set the control mode of the player in_player.controlstyle =Mpmoviecontrolstylefullscreen; - to [Self.view AddSubview:self.player.view]; + } - return_player; the } * $-(ibaction) play {Panax Notoginseng [Self.player play]; - } the + @end
iOS development--simple implementation with MPMoviePlayerController video playback