1

I have an .mp4 video(url) which was protected by Windows authentication. I would like to play using MPMoviePlayerController.

I've implemented some code, and I'm sure I'm close!

So, I'm trying to "unlock" the mp4 url using NSURLConnection. It works, but when I try to access the same url with initWithContentURL, it doesn't work. (it cannot "see" that I've entered the info previously.

So, the question was; how do I onlock a folder/url permanently, OR how can I provide MPMoviePlayerController a NSURLConnection instead of NSURL.

1- So, here's the steps I've taken:

- (void)viewDidLoad{
    [super viewDidLoad];
    //[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL       URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]]];
    [self tryConnection];
}

2--> I'm trying to access the protected URL(this was working)

- (void) tryConnection{
    NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.abcd.com/_develop/video/01.mp4"]];
    NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
                         //[request release];
                         //[connection release];
}

3- this was called properly

- (BOOL)connection:(NSURLConnection*)conn  canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace*)protectionSpace {  
    if([[protectionSpace authenticationMethod] isEqualToString:NSURLAuthenticationMethodNTLM])  
        return YES;  

    // Explicitly reject ServerTrust. This is occasionally sent by IIS.  
    if([[protectionSpace authenticationMethod] isEqualToString:NSURLAuthenticationMethodServerTrust])  
        return NO;  

    return NO;  
}  

4- this was called properly

- (void)connection:(NSURLConnection*)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge{
    NSLog(@"didReceiveAuthenticationChallenge");
        if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM])
            [[challenge sender] useCredential:[NSURLCredential  
                                          credentialWithUser:@"1234"  
                                          password:@"5678"  
                                          persistence:NSURLCredentialPersistenceNone] forAuthenticationChallenge:challenge]; 

}

4- this was called properly. From here, that's great because i know that the url was Unlock. So... how to play it with MPMoviePlayer?

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;{
    NSLog(@"received response via nsurlconnection");
    [self moviePlayerGO];
}

4- Stay black... :(

-(void)moviePlayerGO{
    NSURL *movieURL = [NSURL URLWithString:@"http://www.abcd.com/_develop/video/01.mp4"];
    //NSURL *movieURL = [NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    moviePlayer.shouldAutoplay = YES;
    [[moviePlayer view] setFrame: CGRectMake(0.0, 0.0, 350.0, 250.0)]; // 2X the native resolution
    [self.view addSubview: [moviePlayer view]];
}
4

0 に答える 0