侦听将在corona sdk中触发的localfile.html webview事件

侦听将在corona sdk中触发的localfile.html webview事件,webview,lua,listener,coronasdk,Webview,Lua,Listener,Coronasdk,我正在构建一个简单的应用程序,需要我使用webview选项 local physics = require( "physics" ) local composer = require ( "composer" ) Create a composer scene for this module local scene = composer.newScene() function scene:create( event ) local sceneLanding = self.view local

我正在构建一个简单的应用程序,需要我使用webview选项

local physics = require( "physics" )
local composer = require ( "composer" )
Create a composer scene for this module
local scene = composer.newScene()
function scene:create( event )
local sceneLanding = self.view


local soundID = audio.loadSound ("gummy_music.wav")


local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, 480 )
webView:request( "page.html", system.ResourceDirectory )
webView:addEventListener( "urlRequest", webListener )
页面拉起并呈现良好效果

我试图弄清楚如何使用coronasdk中的listener函数在本地html文件中发生事件时播放声音

我的网页上有这样的东西,卢阿

local function webListener( event )
audio.play( soundID )
end

我正在寻找一种使用jquery点击webListener播放音频的方法

您可以向HTML文件添加链接,如

<a href="corona://playsound">Play sound</a>

这应该可以做到

谢谢,但当我点击链接时,它会转到404类型的页面奇怪,无论如何。。。您可以始终使用,但需要在event.url字符串中搜索“playsound”子字符串
local function webListener( event )
    if (event.url and event.url == "corona://playsound") then
        audio.play( soundID )
    end
end