0

我尝试使用以下 URL 播放来自 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.movi​​ePlayerController = // [[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");
}

感谢您的帮助 !

4

1 回答 1

0

DropBox 不允许直接访问它的文件,您只能使用它的 api 从 DropBox 访问文件。所以

首先,我希望您尝试以这种方式获取视频的短 URL,并在本机播放器中提供该 URL

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 是否支持直播

于 2013-11-15T09:55:39.577 回答