How to play video using MPMoviePlayerController in iphone?

This is my code for downloading videos using MPMoviePlayerController. My problem: I hear the voice of the video, but I do not see the video. can anyone give me a solution?

note: "AddRunningClient start device on non-zero client count" this message is displayed when I launch the application in the console

I am now working with IOS4.1 sdk

   - (void)viewDidLoad {
     [super viewDidLoad];

     NSString *mediaPath = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"understandingoilcost_1500kbps.mov"];

    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:mediaPath]];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    [moviePlayer play];
}

Please help me!

Thank.

+3
source share
1 answer

This is because you have not added the player view to your view. You need to do something like this:

[[moviePlayer view] setFrame:[[self view] bounds]];
[[self view] addSubview: [moviePlayer view]];

, , ( ).

+9

Source: https://habr.com/ru/post/1769322/


All Articles