iPhone 应用程序中 YouTube 视频完成的通知

发布于 2024-10-16 15:38:06 字数 360 浏览 2 评论 0原文

我已经按照 YouTube API 博客的方法 #2 毫无困难地嵌入了 YouTube 视频:

http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

有什么方法可以知道视频何时播放播放完毕(或者当用户按下影片控制器上的“完成”按钮时)?

例如,假设您想要播放播放列表中的每个视频,而不需要用户与应用程序交互。有什么时间开始下一个视频的钩子吗?

I've embedded the YouTube video with no difficulties following method #2 of the YouTube API Blog:

http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

Is there any way to know when the video has finished playing (or when the user presses the Done button on the movie controller)?

For instance, say you wanted to play each video in a playlist without requiring the user to interact with the app. Is there any hook for when to start the next video?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

看春风乍起 2024-10-23 15:38:06

恐怕你运气不好。我大约六个月前搜索过同样的事情,并得出结论:当前的 SDK 不可能实现这一点。我也在堆栈溢出中发布了类似的问题。

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

一般来说,如果你需要这种功能,你必须使用 MPMoviePlayerCOntroller,不是 Web 视图。即使如此,我也不认为此类支持 YouTube URL。

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.

蒗幽 2024-10-23 15:38:06

根据 smoothlandon 的帖子,这是我用来确定 YouTube/Safari 窗口是否仍然处于活动状态的方法。我的应用程序非常简单,它只有主窗口和加载的 YouTube/Safari 视图。

视图加载:

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");
  }
}

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");
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文