(1) Using media playback, you need to load the <MediaPlayer/MediaPlayer.h> frame first, and #import import. Several points to note about media playback are:
-Full screen settings need to be set after the view is visible to be valid.
--all kinds of control is realized by notification Nsnotificationcenter, there is a full screen to enter/exit, play pause state change and so on.
#import "WPMoviePlayController.h" #import <MediaPlayer/MediaPlayer.h> @interface Wpmovieplaycontroller () @ Property (Nonatomic,strong) MPMoviePlayerController *movie; @end @implementation wpmovieplaycontroller-( MPMoviePlayerController *) movie{if (_movie==nil) {//Get file path directly to URL, success Nsurl *url=[[nsbundle Mainbundle]ur lforresource:@ "A.mp4" withextension:nil]; _movie=[[mpmovieplayercontroller Alloc]initwithcontenturl:url]; _movie.view.frame=self.view.bounds; [Self.view Addsubview:_movie.view]; } return _movie;} -(void) viewdidload{[Super Viewdidload]; [Self.movie play]; [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (enterfullscreen) Name: Mpmovieplayerdidenterfullscreennotification Object:nil]; [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (exitfullscreen) Name: Mpmovieplayerdidexitfullscreennotification Object:nil];} -(void) Viewdidappear: (BOOL) animated{//setting This property to YES BEfore the movie player ' s view is visible would have no effect. This property needs to be set only after the movie player object view is rendered, the light load does not work, it needs to wait for the appear after setting, so use Self.movie.fullscreen=yes in this method;} -(void) enterfullscreen{NSLog (@ "Go full Screen");} -(void) exitfullscreen{[Self.movie stop]; [Self dismissviewcontrolleranimated:yes completion:nil]; NSLog (@ "exit full screen");}
(2) What is the runtime?
--That's all the things that each method/function calls between each other.
--In most cases, the runtime runs silently behind the scenes, and it is primarily used to write and compile OC source programs
--using clang to compile the OC source program (such as MAIN.M) into the CPP code, so that you can see the underlying runtime implementation of the principle, is to understand the principle of OC underlying one of the methods.
CLANG-REWRITE-OBJC main.m
A main.cpp file is generated, and then
Open main.cpp
can be viewed.
Interview: Did you use runtime development?
Answer: Runtime is the method call between those things, is to do the bottom, I sometimes use clang to decompile the source code into C + +, nothing to see the underlying implementation principle.
The use of MPMoviePlayerController class video playback in the iOS Dev-97 MediaPlayer framework and Runtime runtime