我没有收到任何通知MPMoviePlayerController.我究竟做错了什么?
我使用以下逻辑.
我开始播放youtube视频了UIWebView.UIWebView称之为标准MPMoviePlayerController.我不控制MPMoviePlayerController因为我没有实例化MPMoviePlayerController.
我使用自动播放运行youtube的剪辑(延迟1秒):
[self performSelector:@selector(touchInView:) withObject:b afterDelay:1];
Run Code Online (Sandbox Code Playgroud)
我的代码是:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[self embedYouTube];
}
- (void)loadStateDidChange:(NSNotification*)notification
{
NSLog(@"________loadStateDidChange");
}
- (void)playbackDidFinish:(NSNotification*)notification
{
NSLog(@"________DidExitFullscreenNotification");
}
- (void)embedYouTube
{
CGRect frame = CGRectMake(25, 89, 161, 121);
NSString *urlString = [NSString stringWithString:@"http://www.youtube.com/watch?v=sh29Pm1Rrc0"];
NSString *embedHTML = @"<html><head>\
<body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>"; …Run Code Online (Sandbox Code Playgroud) youtube mpmovieplayercontroller mpmovieplayer nsnotificationcenter ios