Notification of YouTube video completion in iPhone app

耗尽温柔 提交于 2019-11-29 11:34:51
Jose Cherian

I am afraid you are out of luck. I have searched for the same thing around six months before and came to the conclusion that it is not possible with the current SDK. I have posted a similar question in stack overflow too.

https://stackoverflow.com/questions/4011796/notification-after-video-playback-in-mobile-safari

In general, if you need this kind of functionality, you have to use MPMoviePlayerCOntroller, not a web view.Even then, I don't think youtube URLs are supported by this class.

Going by smoothlandon's post, this is what I implemented to determine if the YouTube/Safari window is still active. My App is really simple and it only has the main window, and a YouTube/Safari view that loads.

viewDidLoad:

activeWindow = [[UIApplication sharedApplication] keyWindow];
windowTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkForMedia) userInfo:nil repeats:YES];


- (void) checkForMedia{
  newWindow = [[UIApplication sharedApplication] keyWindow];

  if(newWindow == activeWindow){

  NSLog(@"media is not playing");

  }else{
      NSLog(@"media is playing");
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!