视频流MpMoviePlayerController与Tomcat服务器

时间:2014-06-18 12:26:17

标签: ios video-streaming tomcat7 mpmovieplayercontroller

过去几天我遇到了一个问题。我无法在iOS上播放视频流,并传递凭证以确保安全。

每次我得到以下错误:

  

Domain = MediaPlayerErrorDomain Code = -11850“Operation Stopped”UserInfo = 0xb6115d0 {NSLocalizedDescription = Operation Stopped}

这是我的代码:

NSURLCredential *credential = [[NSURLCredential alloc]
    initWithUser:[[NSUserDefaults standardUserDefaults]valueForKey:emailAddress]
    password:[[NSUserDefaults standardUserDefaults] valueForKey:USER_PASSWORD]
    persistence: NSURLCredentialPersistencePermanent];

NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] 
    initWithProxyHost:@"aaa.aaa.aaa.aa" port:80 type:NSURLProtectionSpaceHTTP
    realm:@"PortalRealm"   authenticationMethod:nil];    
[[NSURLCredentialStorage sharedCredentialStorage]
    setDefaultCredential:credential
    forProtectionSpace: protectionSpace];

NSURL *URL = [NSURL URLWithString:string];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL
    cachePolicy:NSURLRequestUseProtocolCachePolicy
    timeoutInterval:30.0];
NSURLConnection *connection = [[NSURLConnection alloc]
    initWithRequest:request delegate:self];
[connection start];

if (url != nil)
{
    self.moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
    [self addVideoNotification];
    self.moviePlayer.view.frame = CGRectMake(0, self.myImage.frame.origin.y,  
        self.myImage.frame.size.width, self.myImage.frame.size.height);
    [self.moviePlayer prepareToPlay];
    UIImage *thumbnail = [self.moviePlayer thumbnailImageAtTime:1.0
        timeOption:MPMovieTimeOptionNearestKeyFrame];
    [self.view addSubview:self.moviePlayer.view];
    self.myImage.image = thumbnail;
    [self.moviePlayer play];
}

提前致谢。

0 个答案:

没有答案