UIWebview
加载UIWebview
myWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH, imageHeigh)];
movieUrl = [NSString stringWithFormat:@"www.nicaicai.com/xxxx.mp4"];
NSURL *url = [NSURL URLWithString:movieUrl];
myWeb.scrollView.scrollEnabled = NO;
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWeb setDelegate:self];
[myWeb loadRequest:request];
[scrollView addSubview:myWeb];
监听
- (void)addNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(beginPlayVideo:)
name:UIWindowDidBecomeVisibleNotification
object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(endPlayVideo:)
name:UIWindowDidBecomeHiddenNotification
object:self.view.window];
}
- (void)removeNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIWindowDidBecomeVisibleNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIWindowDidBecomeHiddenNotification
object:nil];
}
-(void)beginPlayVideo:(NSNotification *)notification{
NSLog(@"播放");
}
-(void)endPlayVideo:(NSNotification *)notification{
NSLog(@"结束");
}