我正在使用MPMoviePlayerController播放「.3gp」視頻,我從服務器獲取數據並將其保存在NSData對象中,然後將其寫入Document目錄中的文件,這裏是我的代碼MPMoviePlayerController不工作在iOS 5上
在.hi在.m文件中定義錄像機爲
@interface MainViewController : UIViewController {
MPMoviePlayerController* videoPlayer; }
@property (strong, nonatomic) MPMoviePlayerController* videoPlayer;
-(void)videoWillStartPlayWithUrl:(NSData *)d
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myMove.3gp"];
[d writeToFile:path atomically:YES];
NSURL *url = [NSURL fileURLWithPath:path];
adBannerView.hidden = YES;
self.videoPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
self.videoPlayer.controlStyle = MPMovieControlStyleEmbedded;
self.videoPlayer.shouldAutoplay = YES;
[self.videoPlayer.view setFrame: self.view.bounds];
[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer setFullscreen:YES animated:YES];
[self.videoPlayer prepareToPlay];
[self.videoPlayer play];
}
它在iOS中可以正常使用5但在iOS 5中它只是顯示一個黑屏並直接退出,我似乎無法找到阻止視頻在iOS 5中播放的問題,非常感謝
我應該發送消息給玩家或self.myPlayer? [self.myPlayer play]或[player play] – ahmad
self.myplayer.also唯一需要注意的是你必須在這裏使用強關鍵詞 –
thnx很多,但它不工作!接收到「MPMoviePlayerPlaybackDidFinishNotification」,並且播放器從視圖中移除而不顯示除播放器界面和其頂部的播放器界面和加載指示符之外的任何內容!任何其他的想法? – ahmad