[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];

}

posted @ 2010-03-29 22:48  AlexLiu  阅读(571)  评论(0编辑  收藏  举报