关闭视频后删除视频缩略图(“完成”按钮)
我正在处理由我的公司托管的 mp4 视频,而不是 YouTube。
我使用以下代码在 UIWebView 中创建可单击的缩略图:
videoButtonHTML = [videoButtonHTML stringByAppendingFormat:@"<body bgcolor=\"#000000\"><a href=\"%@/\"><img src=\"%@\" width=\"120\" height=\"90\" border=\"0\" type=\"application/x-shockwave-flash\"/></a></body>", videoURL, self.imageLink];
[videoButtonWebview loadHTMLString:videoButtonHTML baseURL:nil];
起初效果很好。它创建缩略图并播放视频。问题是,当您关闭视频时,缩略图就会消失。我仍然有“空白”Quicktime 播放图像。不过我真的很想保留这个形象。
我已经尝试过使用和不使用冲击波标签 - 相同的结果。我在教程中发现了 embedYoutube 功能。它适用于 YouTube 视频,但不适用于 mp4 视频。这是该代码,以防有帮助:
- (void)embedYouTube1:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
知道发生了什么吗?
I am working with mp4 videos hosted by my company, not YouTube.
I am using the following code to create a clickable thumbnail in a UIWebView:
videoButtonHTML = [videoButtonHTML stringByAppendingFormat:@"<body bgcolor=\"#000000\"><a href=\"%@/\"><img src=\"%@\" width=\"120\" height=\"90\" border=\"0\" type=\"application/x-shockwave-flash\"/></a></body>", videoURL, self.imageLink];
[videoButtonWebview loadHTMLString:videoButtonHTML baseURL:nil];
This works fine at first. It creates the thumbnail and plays the video. The problem is that, when you close the video, the thumbnail image disappears. I still have the "blank" Quicktime play image. I really want to keep the image, though.
I've tried this both with and without the shockwave tag - same result. I found an embedYoutube function in a tutorial. It works great with YouTube videos, but not with mp4 videos. Here's that code, in case it helps:
- (void)embedYouTube1:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
Any idea what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将图像保存为
NSData
,也许保存到您的NSUserDefaults
(加载视频时),然后您可以显示 中的拇指默认值,而不是视频本身(当视频未加载时)。Try saving the image as
NSData
, maybe to yourNSUserDefaults
(when the video is loaded), then you can display the thumb from defaults, instead of the video itself (when the video is not loaded).