本文介绍了如何从类型为.3gp的URL播放视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
提前致谢。我想实现代码从URL以编程方式在iphone中播放视频。我写了这样的代码。
Thanks in advance. I want to implement the code to play a video in iphone programatically from URL. I have written the code like this .
NSURL *url = [NSURL URLWithString:@"http://91.220.127.40/Celebrity_subCategoryItems/rc4.3gp"];//@"http://www.businessfactors.de/bfcms/images/stories/videos/defaultscreenvideos.mp4"];
MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL: url];
[[player view] setFrame: [self.view bounds]]; // frame must match parent view
[self.view addSubview: [player view]];
[player play];
但它没有播放.3gp类型的文件。如果有人知道请帮帮我。
but it is not playing the file of type .3gp. If any one know please help me.
推荐答案
我用iphone sdk成功播放.3gp,我的代码是:
I have played successfully .3gp with iphone sdk and my code is :
NSString *soundLocalPath = [[NSBundle mainBundle] pathForResource:@"Demo_video" ofType:@"3gp"];
NSURL *tempUrl = [NSURL fileURLWithPath:soundLocalPath];
self.soundUrlPath = tempUrl;
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: self.soundUrlPath];
self.mpMoviePlayer = player;
[player release];
[self.mpMoviePlayer prepareToPlay];
[self.mpMoviePlayer.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: self.mpMoviePlayer.view];
[self.mpMoviePlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
-(void) movieFinishedCallback:(NSNotification*) aNotification
{
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player autorelease];
}
这篇关于如何从类型为.3gp的URL播放视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!