0
votes

I try to play video from dropbox with this URL:http://www.dropbox.com/s/usqbtrjgcxu0ac6/pandaw.m4v but when I play, it become black and I am struck.

Can anyone tell me how to define the url here, I think my url is not correct that why I cannot play.

My code:

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");
}

Thank for your help !

1

1 Answers

0
votes

DropBox don't allow direct access of it's file you can only access file from DropBox by using it's api. So

First I want to you to try get video's shorted URL in this way and supply that url in native player

NSString *urlString=[NSString stringWithFormat:@"https://api.dropbox.com/1/shares/dropbox%@?access_token=%@",selectedImagePath,dropBoxToken];

If still not success then only way is to download file, you can download file in this way.

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];

Note: I don't know DropBox support live streaming or not