我正在试图从lib中播放视频,但我不能弄清楚做什么我错了我已经尝试了许多东西,它没有显示任何类型的错误我的代码如下问题采摘视频和玩它
- (void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
NSURL *url = [[NSURL alloc]initWithString:mediaType];
NSLog(@"%@",url);
[self dismissModalViewControllerAnimated:NO];
/* Create a new movie player object. */
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
if (player)
{
/* Specify the URL that points to the movie file. */
[player setContentURL:url];
/* Add a background view as a subview to hide our other view controls
underneath during movie playback. */
CGRect viewInsetRect = CGRectInset ([self.view bounds],
kMovieViewOffsetX,
kMovieViewOffsetY);
/* Inset the movie frame in the parent view frame. */
[[player view] setFrame:viewInsetRect];
[player view].backgroundColor = [UIColor lightGrayColor];
/* To present a movie in your application, incorporate the view contained
in a movie player’s view property into your application’s view hierarchy.
Be sure to size the frame correctly. */
[self.view addSubview: [player view]];
[player setCurrentPlaybackRate:0.5];
[player play];
}
// Register for the playback finished notification
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(myMovieFinishedCallback:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: player];
}
// When the movie is done, release the controller.
-(void) myMovieFinishedCallback: (NSNotification*) aNotification
{
MPMoviePlayerController *playerr = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
object:playerr];
[playerr stop];
[self.view removeFromSuperview];
[playerr autorelease];
}
发生了什么是第一presetModelViewController
越来越显示,然后我可以显示在我的lib中的视频,我可以选择其中之一,但是当我选择视频,然后它显示我的灰色视图,没有别的,我的视频没有播放。
如果你可以在我的代码中发现任何错误,并可以帮助我,那么这将是很大的帮助。
,您可以发送的NSString * mediaType的的日志。 – spider1983
让我向你展示 – java
它打印public.movie – java