首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

MPMoviePlayerViewController兑现

2012-08-10 
MPMoviePlayerViewController实现1、要使用MPMoviePlayerViewController首先要加入MediaPlayer.framework.?

MPMoviePlayerViewController实现

1、要使用MPMoviePlayerViewController首先要加入MediaPlayer.framework.?
2、加入如下代码:?

"mp4"];??
  • ??????
  • ????MPMoviePlayerViewController?*playerViewController?=?[[MPMoviePlayerViewController?alloc]?initWithContentURL:[NSURL?fileURLWithPath:url]];??
  • ????[[NSNotificationCenter?defaultCenter]?addObserver:self?selector:@selector(movieFinishedCallback:)??
  • ?????????????????????????????????????????????????name:MPMoviePlayerPlaybackDidFinishNotification??
  • ???????????????????????????????????????????????object:[playerViewController?moviePlayer]];??
  • ????//--?add?to?view---??
  • ????[self.view?addSubview:playerViewController.view];??
  • ??????
  • ????//---play?movie---??
  • ????MPMoviePlayerController?*player?=?[playerViewController?moviePlayer];??
  • ????[player?play];??
  • ??????
  • }??
  • ??
  • -?(void)?movieFinishedCallback:(NSNotification*)?aNotification?{??
  • ????MPMoviePlayerController?*player?=?[aNotification?object];??
  • ????[[NSNotificationCenter?defaultCenter]?removeObserver:self?name:MPMoviePlayerPlaybackDidFinishNotification?object:player];??
  • ????[player?stop];??
  • ????[self.view?removeFromSuperView];??
  • ????[player?autorelease];??
  • }??
    3、支持横屏修改shouldAutorotateToInterfaceOrientation:interfaceOrientation方法使其返回YES。

  • 热点排行