我尝试使用此网址从Dropbox播放视频:http://www.dropbox.com/s/usqbtrjgcxu0ac6/pandaw.m4v但是当我播放时,它会变黑并且我很震惊。
有谁能告诉我如何在这里定义网址,我认为我的网址不正确,为什么我不能玩。
我的代码:
self.moviePlayerController =
[[MPMoviePlayerController alloc] initWithContentURL:[[NSURL alloc] initWithString:@"http://www.dropbox.com/s/usqbtrjgcxu0ac6/pandaw.m4v"]];//http://www.youtube.com/watch?v=x3TIBhQy3XY
// NSString * videoFileName = [[NSBundle mainBundle] pathForResource:@“pandaw”ofType:@“m4v”inDirectory:nil]; // self.moviePlayerController = // [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:videoFileName]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidExitFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
[self.moviePlayerController prepareToPlay];
self.moviePlayerController.backgroundView.backgroundColor=[UIColor purpleColor];
[self.moviePlayerController setFullscreen:YES];
self.moviePlayerController.useApplicationAudioSession = NO;
self.moviePlayerController.movieSourceType=MPMovieSourceTypeStreaming;
[self.moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:self.moviePlayerController.view];
if (self.moviePlayerController.isPreparedToPlay==YES) {
[self.moviePlayerController play];
}else{
NSLog(@"not yet finish in preparing");
}
感谢您的帮助!
答案 0 :(得分:0)
DropBox不允许直接访问它的文件,你只能使用它的api从DropBox访问文件。所以
首先,我希望您以这种方式尝试获取视频的短网址并在原生播放器中提供该网址
NSString *urlString=[NSString stringWithFormat:@"https://api.dropbox.com/1/shares/dropbox%@?access_token=%@",selectedImagePath,dropBoxToken];
如果仍然没有成功那么只有下载文件的方式,你可以这样下载文件。
NSString *imageUrlString=[NSString stringWithFormat:@"https://api-content.dropbox.com/1/files/dropbox%@?access_token=%@",path,dropBoxToken];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:imageUrlString]];
[theRequest setHTTPMethod:@"GET"];
NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
注意:我不知道DropBox是否支持直播