尝试在webview中让视频不全屏的Corona SDK

我正在尝试在Webview中展示视频,但在iPhone上不要全屏显示。

我已经阅读了我在堆栈上找到的每篇文章,但我仍然有问题。

在iPad中一切都很完美,但在iPhone上不行。

我认为这个代码不正常工作:

webView:setNativeProperty("allowsInlineMediaPlayback", true)

这里是文档:https://docs.coronalabs.com/api/type/NativeDisplayObject/setNativeProperty.html

我的Lua代码:

local webView = native.newWebView(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight)
webView:setNativeProperty("allowsInlineMediaPlayback", true)
webView:setNativeProperty("mediaPlaybackRequiresUserAction", false)
webView:request("example_full.html", system.ResourceDirectory)

local function webViewListener(event)
  if event.type then
    print("The event.type is " .. event.type)--print the type of request
    if (event.type == "other") then
      if event.url == "js-call:myEvent" then
        print("ciao")
        webView:removeSelf()
        webView = nil
      end
    end
  end
  if event.errorCode then
    native.showAlert("Error!", event.errorMessage, {"OK"})
  end
end
webView:addEventListener("urlRequest", webViewListener)

我的html文件:

<!DOCTYPE html>
<html>

<head>
  <title>HTML5 InStream Ad Framework - Simple Video Page</title>
  <script type="text/javascript" src="instreamapi-2.1.2.min.js"></script>
</head>

<body>
  <div style="position:relative">
    <video id="vid1" width="100%" height="100%" style="background-color:black" poster="http://cdn.smartclip.net/html5framework/smartclip_multisreen.png" controls url="" playsinline webkit-playsinline>
      <source src="media/bbb_trailer_iphone.mp4" type="video/mp4" />
      <source src="media/bbb_trailer_iphone.ogv" type="video/ogg" />
      <source src="media/bbb_trailer_iphone.webm" type="video/webm" />
    </video>
  </div>
  <script type="text/javascript" language="javascript">
    window.onload = (function() {
      var myAdConfig = {
        preroll: 'http://des.smartclip.net/ads?t=de&p=9372&pl=testc&test=ms_vast2_socialmenu&sz=400x320&rnd=[random]',
        overlayDelay: 3,
        overlayDuration: 25,
        adCountdownText: 'This ad remains [time] seconds',
        onFinish: function() {
          //console.log("ciao");
          //window.location = "js-call:myObjectiveCFunction"
          window.location.href = "js-call:myEvent";
        }
      }

      $ad('vid1', myAdConfig).start();
    });
  </script>
</body>

</html>

我有一个工作的Objective-C项目,但我不知道如何让它在Corona中工作,也不知道如何使用Corona Enterprise。

非常感谢您的帮助,对我的英语表示抱歉。

Federica

点赞
用户4244734
用户4244734

我通过 Corona Support 找到了解决方案。

他们告诉我:

Hello!感谢你的报告。由于一些神秘的原因,object:setNativeProperty 和 object:getNativeProperty 以点语法而不是对象风格的调用方式进行设置。基本上,如果你尝试进行 webView.setNativeProperty("allowsInlineMediaPlayback", true) 的调用,一切都应该可以工作。(不同之处在于"."而不是“:”)这个问题将在即将发布的版本中修复,但是出于向后兼容的原因,我们仍将支持点语法。Vlad.

2016-02-08 11:09:16