我試圖在MPMoviePlayercontroller
中按下按鈕上的某種通知。問題是,按下按鈕時我沒有收到任何類型的通知。我爲此使用NSNotification
。爲什麼我沒有收到通知?MPMoviePlayerController中的NSNotification
ViewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(exitedFullScreen)
name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
和方法
-(void) exitedFullScreen
{
NSLog(@"TEST");
}
代碼來調用MPMoviePlayer
:
NSString *youTubeVideoHTML = @"<!DOCTYPE html><html><head><style>body{margin:0px 0px 0px 0px;}</style></head> <body> <div id=\"player\"></div> <script> var tag = document.createElement('script'); tag.src = \"http://www.youtube.com/player_api\"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; function onYouTubePlayerAPIReady() { player = new YT.Player('player', { width:'%0.0f', height:'%0.0f', videoId:'%@', events: { } }); } function onPlayerReady(event) { event.target.playVideo(); } </script> </body> </html>";
NSString *embedHtml = [NSString stringWithFormat: youTubeVideoHTML,
webView.frame.size.width,
webView.frame.size.height,
youtubeId[0]];
webView.mediaPlaybackRequiresUserAction = NO;
[webView loadHTMLString: embedHtml baseURL: [NSURL URLWithString: @"http://youtube.com"]];
如何創建webView是它的類屬性還是局部變量? – kkocabiyik
我用過的屬性 @property(弱,非原子)IBOutlet UIWebView * webView; – user3140296
你沒有任何MPMoviePlayer,你期待從MPMoviePlayer – kkocabiyik