0

我正在为 iPhone 开发一个应用程序,我在其中运行 Youtube 视频UIwebView。在那,我想检索有关视频的所有信息(视频何时开始以及完成视频所需的时间)。我试图每 2 秒获取一次此信息。

我无法得到这样的通知。我也尝试过用 JavaScript 来做这件事,但我在某处读到它需要 Flash Player 而 iPhone 不支持它。所以 JavaScript 不是一个选项。

谁能建议我如何从这里继续前进?谢谢。

我的代码:

//
//  YouTubeEmbedViewController.m
//  YouTubeEmbed
//
//  Created by Movik Networks on 11/04/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "YouTubeEmbedViewController.h"

@implementation YouTubeEmbedViewController
@synthesize thumbnailView;

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    // webView is a UIWebView, either initialized programmatically or loaded as part of a xib.

    NSString *htmlString = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 300\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"300\" height=\"300\"><param name=\"movie\" value=\"http://www.youtube.com/watch?v=oSOooSv1RH0\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/watch?v=oSOooSv1RH0\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"300\" height=\"300\"></embed></object></div></body></html>";

    [thumbnailView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.google.com"]];

}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
4

1 回答 1

0

您可以将Youtube API 与客户端库一起使用

然后您可以播放文件MPMoviePlayerViewController并使用它的委托功能。

于 2012-04-09T12:08:55.727 回答