This is how I would structure your code
@interface Video : NSObject @property ( nonatomic, strong, readonly ) MPMoviePlayerController * videoView ; @end @implementation Video @synthesize videoView = _videoView ; +(Video *)sharedSingleton { static Video * __sharedSingleton ; static dispatch_once_t once ; dispatch_once( &once, ^{ __sharedSingleton = [ [ [ self class ] alloc ] init ] ; } return __sharedSingleton ; } -(void)dealloc { [ _videoView stop ] ; [ _videoView.view removeFromSuperview ] ; } -(void)ensureMoviePlayer { if (!_videoView ) { NSURL* url = [[NSBundle mainBundle] URLForResource:@"videoName" withExtension:@"mp4"]; _videoView = [[MPMoviePlayerController alloc] initWithContentURL:url]; } } - (void)addVideoOn:(UIView*)view { [ self ensureMoviePlayer ] ; self.videoView.view.frame = view.bounds ;
If you are trying to play a video with a specific size in the parent view, see AVPlayer
+ AVPlayerLayer
source share