gpt4 book ai didi

iphone - UIWebView 自动播放视频

转载 作者:可可西里 更新时间:2023-11-01 05:31:38 24 4
gpt4 key购买 nike

您好,我有一个 WebView ,当我尝试在其中加载视频文件时,它会自动开始播放视频,无需用户干预。而且播放按钮仍然显示在 webview 中(视频在后面播放)。我正在使用以下代码加载 URL

NSURL*  url = [NSURL fileURLWithPath:filePath];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];

你能告诉我如何禁用播放按钮或者视频应该只有在用户点击播放按钮后才开始播放吗??

最佳答案

- (void)videoThumb:(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];

[webView loadHTMLString:html baseURL:nil];
[self.view addSubview:webView];
[webView release];
}

//Include above function to your page and call it by passing the urlstring
[self videoThumb:url:frame];


//frame : this parameter needs the size of the thumb you want to use.

我希望这可以帮助您并更好地实现您的目的。

关于iphone - UIWebView 自动播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9992735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com