Search code examples
iosstreammpmovieplayercontroller

MPMoviePlayerController: stream https URLs failed


I searched all the similar question but helpless. It's about streaming https://172.16.58.100:8443/test02.mp4 URL using MPMoviePlayerController.


I use MPMoviePlayerController to stream videos and play in my app. URLs like http://172.16.58.100:8080/test.mp4 is ok, MPMoviePlayerController works fine.

But URLs like https://172.16.58.100:8443/test02.mp4, MPMoviePlayerController does not work, it returns MPMovieFinishReasonPlaybackError . I know it means the videoPlayer init failed and caused MPMoviePlayerPlaybackDidFinishNotification . I have no idea how to do this.

I also tried this:

NSURLCredential *credental = [[NSURLCredential alloc]initWithUser:@"tomcat"
                                                         password:@"123456"
                                                      persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectSpace = [[NSURLProtectionSpace alloc]initWithHost:@"172.16.58.100"
                                                                          port:8443
                                                                      protocol:@"http"
                                                                         realm:nil
                                                          authenticationMethod:NSURLAuthenticationMethodDefault];
[[NSURLCredentialStorage sharedCredentialStorage]setDefaultCredential:credental forProtectionSpace:protectSpace];

NSURL *fileURL = [NSURL URLWithString:@"https://172.16.58.100:8443/test.mp4"];
[self.moviePlayer playMovieFile:fileURL];

But it still show the same error(init failed and enter MPMoviePlayerPlaybackDidFinishNotification)

=============================

I mean I just want to know How stream URLs like "https://xxx.xxx.xx.mp4" by MPMoviePlayerController.

Any suggestion? Merry Christmas.


Solution

  • maybe I made a mistake on server configuration; now change to webDav, streaming http&https works fine.