我已成功将嵌入式vimeo视频应用到我的应用中,但是我想在视频播放时创建占位符图像作为叠加层。有没有人知道如何做到这一点?
#import "FifthDetailViewController.h"
@interface FifthDetailViewController (Private)
- (void)embedVimeoInWebView:(NSString *)urlString webView: (UIWebView *)aWebView;
@end
@implementation FifthDetailViewController
@synthesize toolbar;
@synthesize videoOne;
#pragma mark -
#pragma mark View lifecycle
- (void) viewDidLoad{
[super viewDidLoad];
[self embedVimeoInWebView:@"http://player.vimeo.com/video/19967404" webView:videoOne];
}
- (void)embedVimeoInWebView:(NSString *)urlString webView:(UIWebView *)aWebView {
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:-2\">\
<iframe src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></iframe>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, aWebView.frame.size.width, aWebView.frame.size.height];
//UIWebView *aWebView = [[UIWebView alloc] initWithFrame:frame];
[aWebView loadHTMLString:html baseURL:nil];
//----Disable Scroll UIWebView----
[[[aWebView subviews] lastObject] setScrollEnabled:NO];
//[mainView addSubview:aWebView];
//[self.mainView addSubview:videoView];
[aWebView release];
}
- (void)dealloc {
[toolbar release];
[super dealloc];
}
@end
这是我到目前为止所做的。
答案 0 :(得分:0)
我们使用youtube视频采用的方法如下(我猜你可以用vimeo做类似的事情)。
您需要做的是在webview上设置一个imageview,它应该显示你的vimeo视频的缩略图img(这是我从你的问题中理解的)。
您可以使用Vimeo API检索缩略图图像
To get data about a specific video, use the following url:
http://vimeo.com/api/v2/video/video_id.output
video_id The ID of the video you want information for.
output Specify the output type. We currently offer JSON, PHP, and XML formats.
你会得到三个缩略图,一个用于不同尺寸(小,中,大)。
由于您的imageView将隐藏webview及其上的按钮以开始播放,因此您需要在点击uimageview时执行操作(或者只是在顶部设置uibutton)。然后,选择器应该调用这样的东西:
**
* When webview has loaded, send an action to itself so it starts the video
* playback automatically
*/
- (void)webViewDidFinishLoad:(UIWebView *)_webView {
_webView.hidden = NO;
UIButton *b = [self findButtonInView:_webView];
[b sendActionsForControlEvents:UIControlEventTouchUpInside];
}
- (IBAction) playVideo:(id)sender {
NSString *key = [NSString stringWithFormat:@"%d", [sender tag]];
UIWebView *youtubeView =
[[UIWebView alloc] initWithFrame:CGRectMake(-180, 100, 160, 80)];
youtubeView.tag = 3000;
youtubeView.hidden = YES;
[self.tableView addSubview:youtubeView];
[self embedYouTubeIntoWebview:youtubeView withURL:[[self.nodeCollection objectForKey:
key] valueForKey:@"videoURL"]
inFrame:youtubeView.frame];
[youtubeView release];
}