[iPhone-App]视频播放
网上有,拿来改改。挺好用的。比较简单。分享。
- (void) Playback : (id) sender
{
//指定播放的名字和地址
NSString *path = [[NSBundle mainBundle] pathForResource:@"ss" ofType:@"mov"];
// m4a格式也是允许的。
MPMoviePlayerController* theMovie=[[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] retain];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie play];
}
- (void) setUpForPlay: (NSNotification *) notification
{
UIButton *button = (UIButton *)[self.view viewWithTag:BUTTON_TAG];
// Prepare button for re-starting
[button setTitle:@"Start" forState:UIControlStateNormal];
[button removeTarget:self action:@selector(stopPlayback:) forControlEvents:UIControlEventTouchUpInside];
[button addTarget:self action:@selector(startPlayback:) forControlEvents: UIControlEventTouchUpInside];
}
作者:Alexliu(alex dotNet Learning)
出处:http://alexliu.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,转载请注明。并且保留文章链接。否则保留追究法律责任的权利。