如何播放从nsurlconnection收到的数据

时间:2011-08-12 05:44:37

标签: objective-c nsurlconnection

我尝试播放受密码保护的给定网址的音频。我的身份验证工作正常,但是如何播放之后收到的数据呢?

- (void)viewDidLoad 
{

    NSString *escapedValue = @"http://www.chhotabheem.com/applegga/chhota_bheem_music_lyrics.mp3";
    //NSURL *url = [NSURL URLWithString:escapedValue];

    zipFileConnection = [[[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:escapedValue]] delegate:self] autorelease];

    [super viewDidLoad];

}



- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSLog(@"didReceiveData");

    NSLog(@"%@",data);


  HERE HOW TO PLAY THE RECEIVED DATA

    //player = [[AudioStreamer alloc] initWithURL:url];
//  [player start];

}

-(void)connection:(NSURLConnection *)aConnection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 
{
    NSLog(@"didReceiveAuthenticationChallenge");

    NSURLCredential *newCredential;
    newCredential = [NSURLCredential credentialWithUser:@"ggaindia" password:@"apple@gga" persistence:NSURLCredentialPersistenceNone];
    [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];

}

0 个答案:

没有答案