потоковое мультимедиа http через https от MVMoviePlayerViewController для iphone - PullRequest
1 голос
/ 22 февраля 2012

Я хочу реализовать функцию потоковой передачи мультимедиа по протоколу HTTPS через MVMoviePlayerViewController.Я пытаюсь получить доступ к серверу https по NSURLConnection, а затем открыть медиа с помощью MVMoviePlayerViewController.Я могу успешно открыть URL-адрес изображения с помощью UIWebView с помощью этого метода в симуляторе и устройстве и открыть URL-адрес мультимедиа, такой как mp3 и mp4, с помощью MVMoviePlayerViewController в симуляторе.Странно то, что мне не удается открыть медиа-URL MVMoviePlayerViewController под устройством.Ниже приведен журнал ошибок.

Экземпляр 0x4b4650 класса AVPlayerItem был освобожден, в то время как наблюдатели значения ключа все еще были зарегистрированы в нем.Информация наблюдений была утечка, и даже может быть ошибочно привязана к какому-либо другому объекту.Установите точку останова на NSKVODeallocateBreak, чтобы остановиться здесь в отладчике.Вот текущая информация наблюдения: (Контекст: 0x0, Свойство: 0x208c20> Контекст: 0x0, Свойство: 0xa8626b0>

Ниже приведены некоторые из моих кодов.

-(void)viewDidLoad 
{
    NSString *stringPath = [NSString stringWithFormat:@"https://xxxxx/xxx.mp4";
    NSURL *urlPath = [NSURL URLWithString:[stringPath stringByAddingPercentEscapesUsingEncoding:NSUTF8St ringEncoding]];
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:urlPath];
    NSURLConnection *httpConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease];
}

- (BOOL)connection : (NSURLConnection *)connection canAuthenticateAgainstProtectionSpace : (NSURLProtectionSpace *)protectionSpace 
{
    return YES;
}

- (void)connection : (NSURLConnection *)connection didReceiveAuthenticationChallenge : (NSURLAuthenticationChallenge *)challenge 
{ 
    if ([challenge previousFailureCount] > 0) 
    {
        return;
    }

    NSString *authenticationMethod = challenge.protectionSpace.authenticationMethod;
    if ([authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTru st])
    {
        SecTrustRef secTrustRef = challenge.protectionSpace.serverTrust;
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:secTrustRef forAuthenticationChallenge:challenge];
    } 
    else 
    {
        NSURLCredential *newCredential = [NSURLCredential credentialWithUser:@"adminr" password:@"admin" persistence:NSURLCredentialPersistenceForSession];
        [challenge.sender useCredential:newCredential forAuthenticationChallenge:challenge];
    }
}

- (void)connection : (NSURLConnection *)connection didReceiveResponse : (NSURLResponse *)response
{
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
    assert([httpResponse isKindOfClass:[NSHTTPURLResponse class]]);

    NSLog(@"didReceiveResponse, status code : %d", httpResponse.statusCode);

    NSString *stringPath = [NSString stringWithFormat:@"%@", testPath];
    NSURL *urlPath = [NSURL URLWithString:[stringPath stringByAddingPercentEscapesUsingEncoding:NSUTF8St ringEncoding]];

    if ((httpResponse.statusCode / 100) == 2) 
    {
        MPMoviePlayerViewController *movieViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:urlPath];
        [self presentMoviePlayerViewControllerAnimated:movieView Controller];
    } 
}

ШАГИ ДЛЯ ВОСПРОИЗВОДСТВА

  1. с использованием API-интерфейса NSURLConnection для подключения к ненадежному серверу сертификации https.

  2. Я получу didReceiveAuthenticationChallenge (делегат NSURLConnection) и получу NSURLAuthenticationMethodServerTrust I useeeth.SecTrustRef и NSURLCredential для доступа к ненадежному серверу сертификации https.

  3. Я получу didReceiveAuthenticationChallenge (делегат NSURLConnection) и использую NSURLCredential для установки имени пользователя и пароля для доступа к ненадежному серверу сертификации https.

  4. Я все получаю didReceiveResponse (делегат NSURLConnection) и получаю HTTP-ответ statusCode 200 OK.

  5. Я пытаюсь открыть URL-адрес мультимедиа https с помощью MPMoviePlayerViewController API.

...