我想直播我的视频文件并在iPhone中播放。
我正在使用MPMoviePlayer播放视频。
我在下面的API中指定了网址: - MPMoviePlayerController * theMovie = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
但我的网址要求提供用户凭据,而我无法传递凭据。 请让我知道解决方法或其他一些选项。 等待你的回复。
答案 0 :(得分:2)
我有同样的问题。应该可以通过使用NSURLCredential以某种方式实现,但直到现在我才能弄明白。
更新:我想通了,看看MPMoviePlayerController的文档,你可以看到它是如何工作的。
对我而言,它的工作原理如下:
NSURLCredential *credential = [[[NSURLCredential alloc]
initWithUser: kHTTPSUsername
password: kHTTPSPassword
persistence: NSURLCredentialPersistenceForSession] autorelease];
NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc]
initWithHost: @"my.secret.host"
port: 443
protocol: @"https"
realm: @"secret.host"
authenticationMethod: NSURLAuthenticationMethodDefault] autorelease];
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential: credential forProtectionSpace: protectionSpace];