Video playing automatically in UIWebView(在 UIWebView 中自动播放视频)
问题描述
您好,我有一个 webview,当我尝试在其中加载视频文件时,它会自动开始播放视频,无需用户干预.并且播放按钮仍显示在 webview 中(视频正在播放).我正在使用以下代码来加载 URL
Hi I have a webview and when i tried to load the video files in that , it starts playing the video automatically without user intervention. And also the play button is still displayed in webview (video is playing behind that). I am using the following code to load the URL
NSURL*  url = [NSURL fileURLWithPath:filePath];
NSURLRequest*   request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
你能告诉我如何禁用播放按钮或者视频应该在用户点击播放按钮后才开始播放吗??
Can you tell me how to disable the play button OR the Video should start playing only after the user taps the play button ??
推荐答案
- (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="JUA=" 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.
我希望这可以帮助您并更好地实现您的目的.
I hope this may help you and better way for your purpose.
这篇关于在 UIWebView 中自动播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UIWebView 中自动播放视频
				
        
 
            
        - Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
 - 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
 - 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
 - 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
 - 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
 - 网上有没有好的 UIScrollView 教程? 2022-01-01
 - GPS状态的广播接收器? 2022-01-01
 - SetOnItemSelectedListener上的微调程序错误 2022-01-01
 - URL编码Swift iOS 2022-01-01
 - UITextView 内容插图 2022-01-01
 
