首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mpmovieplayercontroller问题ipad

mpmovieplayercontroller问题ipad
EN

Stack Overflow用户
提问于 2010-07-01 14:50:05
回答 1查看 327关注 0票数 0

嗨,我已经为ipad创建了应用程序,它在资源文件夹中有一个视频文件,当用户点击播放按钮时,它就会播放。它在用户第一次点击播放按钮时起作用,但当用户随后播放视频时,会出现file.The问题,即视频不播放,只有音频是playing.These问题,不是随机发生的,而是以后会发生的。

当我点击播放器右下角的双箭头图标时,当我单击播放器右下角的双箭头图标时,电影将进入全屏,并在视频正在播放的时间显示视频.At。

有人能帮我吗?

下面是我的示例代码

代码语言:javascript
复制
    MPMoviePlayerController *moviePlayer;

} @property (读写,保留) MPMoviePlayerController *moviePlayer;@合成moviePlayer;

代码语言:javascript
复制
    - (void)viewDidLoad {
 [[NSNotificationCenter defaultCenter] 
  addObserver:self
  selector:@selector(movieFinishedCallback:)
  name:MPMoviePlayerPlaybackDidFinishNotification
  object:self.moviePlayer];
 [super viewDidLoad];
    }


    -(IBAction)PlayBtnPressed:(id)sender
{

 NSURL *movieURL;
 NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"title" ofType:@"mp4"];
 movieURL = [NSURL fileURLWithPath:moviePath];
 // Initialize a movie player object with the specified URL
 MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
 if (mp)
 {
  // save the movie player object
  self.moviePlayer = mp;
  [mp release];

  UIInterfaceOrientation orientation = [[UIDevice currentDevice]orientation];
  [self shouldAutorotateToInterfaceOrientation:orientation];
  // Play the movie!
  [self.view addSubview:self.moviePlayer.view];
  [self.moviePlayer play];
 }
}


     - (void) movieFinishedCallback:(NSNotification*) aNotification {
   NSLog(@"movieFinishedCallback aNotification");
     MPMoviePlayerController *player = [aNotification object];
     [[NSNotificationCenter defaultCenter] 
   removeObserver:self
   name:MPMoviePlayerPlaybackDidFinishNotification
    object:player]; 
    [player stop]; 
    [player.view removeFromSuperview];
  }

提前感谢......

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-07-01 15:49:29

看起来movieplayer不会被释放,直到你在同一个电影文件上分配了第二个:

代码语言:javascript
复制
self.moviePlayer = mp;

保留它,但电影完成的部分不做

代码语言:javascript
复制
self.moviePlayer = nil;

可能是它给你带来了麻烦。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3155611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档