(原)在cocos2d中添加媒体播放器
(转载请标明出处:http://ylucy.cnblogs.com)
精简到最简,其实就如下几行:
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"w-cloudy-day-02-iphone" ofType:@"m4v"]; moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]]; moviePlayerViewController.moviePlayer.repeatMode = MPMovieRepeatModeOne; [[[CCDirector sharedDirector] openGLView] addSubview:moviePlayerViewController.view]; [moviePlayerViewController.view setAlpha:0.5]; [[moviePlayerViewController moviePlayer] play];
并在.h中添加
#import "MediaPlayer/MediaPlayer.h"
并添加成员
MPMoviePlayerViewController *moviePlayerViewController;
当然别忘了添加framwork: MediaPlayer.framework