【问题标题】:Delphi IOS Iphone TWebbrowser (Wkwebview) setAllowsInlineMediaPlayback(true) does not workDelphi IOS Iphone TWebbrowser (Wkwebview) setAllowsInlineMediaPlayback(true) 不起作用
【发布时间】:2022-07-07 23:27:03
【问题描述】:

我尝试入站 fmx.TWebbrowser (Delphi 11) 以在 iphone 应用程序中显示 youtube 流。 如果我单击流图片,流将在 iphone 电影播放器​​窗口中打开。所以我必须缩小,才能在应用程序中查看视频。在 Android 设备上它工作正常。另外,当我在 Xcode 中编写应用程序时,我可以设置“内联播放”,并且流在 wkwebview 中内联工作。

在 Delphi/RAD 中,我可以修改 FMX.Webbrowser.Cocoa。可以使用函数 configuration.setAllowsInlineMediaPlayback(true)。如果我之后检查这个,configuration.allowsinlineMediaPlayback 仍然是假的。

例子:

constructor TCommonWebBrowserService.Create; 
var test:Boolean;
begin
 FWebView := TNativeWebViewHelper.CreateAndInitWebView;
 FWebView.configuration.setAllowsInlineMediaPlayback(True);
 test:=FWebView.configuration.AllowsInlineMediaPlayback;

测试仍然是假的。

Apple 写道:setAllowsInlineMediaPlayback 必须在创建时设置。

在 FMX.Webbrowser.Delegate.IOS 有

class function TNativeWebViewHelper.CreateAndInitWebView: WKWebView;
begin
 Result := TWKWebView.Create();
end;

但是没有办法设置.configuration.setAllowsInlineMediaPlayback(True);

在 FMX.Webbrowser.delegate.ios 有一个函数叫做

function TWebViewDelegate.webViewCreateWebViewWithConfigura tion(webView: WKWebView; configuration: WKWebViewConfiguration;navigationAction: WKNavigationAction; windowFeatures: WKWindowFeatures): WKWebView;

但是Delphi不使用这个功能。

这个问题有替代或解决方案吗?

非常感谢。

【问题讨论】:

    标签: ios delphi youtube twebbrowser


    【解决方案1】:

    您可以将 FMX.WebBrowser.Delegate.iOS.pas 复制到您的项目文件夹并修改 TNativeWebViewHelper.CreateAndInitWebView 以设置配置:

    TNativeWebViewHelper.CreateAndInitWebView to set config:
    
    class function TNativeWebViewHelper.CreateAndInitWebView: WKWebView;
    var
      configuration: WKWebViewConfiguration;
    begin
      configuration := TWKWebViewConfiguration.Create;
      configuration.setAllowsInlineMediaPlayback(True);
      configuration.setmediaTypesRequiringUserActionForPlayback(0);
    
      Result := TWKWebView.Wrap(TWKWebView.Alloc.initWithFrame(
        CGRectFromRect(TRectF.Create(0, 0, 0, 0)), configuration));
    end;
    

    【讨论】:

      猜你喜欢
      • 2018-07-21
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      • 1970-01-01
      相关资源
      最近更新 更多