i went with @Rob suggestion.
if anyone cares here’s the code to have embedded youtube on your app:
local filename="story.html" local posY=0 local story = {} story.title = "Title here" story.youTubeId="duOA3FgpZqY" story.description="Description here" local title = story.title or nil local youTubeId=story.youTubeId or nil local path = system.pathForFile( filename, system.TemporaryDirectory ) local fh, errStr = io.open( path, "w" ) if fh then fh:write("\<!doctype html\>\n\<html\>\n\<head\>\n\<meta charset=\"utf-8\"\>") fh:write("\<meta name=\"viewport\" content=\"width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\"/\>\n") fh:write("\<style type=\"text/css\"\>\n html { -webkit-text-size-adjust: none; font-family: HelveticaNeue-Light, Helvetica, Droid-Sans, Arial, san-serif; font-size: 1.0em; } h1 {color:white; font-size:1.25em;} p {color:white; font-size:0.9em; } \</style\>") fh:write("\</head\>\n\<body style=\"background-color:#000000;\"\>\n") if title then fh:write("\<h1\>" .. title .. "\</h1\>\n") end if youTubeId then local videoID = youTubeId local height = math.floor(display.contentWidth / 16 \* 9) fh:write([[\<iframe width="100%" height="]] .. height .. [[" src="https://www.youtube.com/embed/]] .. videoID .. [[?controls=1&fs=1&modestbranding=1&rel=0&showinfo=0" frameborder="0" allowfullscreen\>\</iframe\>]]) end if story.description then fh:write("\n\<p\>"..story.description.."\</p\>") end fh:write( "\n\</body\>\n\</html\>\n" ) io.close( fh ) else print( "Create file failed!" ) end local webListener local webView local function create\_webView() if webView then webView:removeEventListener( "urlRequest", webListener ) display.remove(webView) webView=nil end webView = native.newWebView(0, 0, display.contentWidth, display.actualContentHeight - posY) webView.x = display.contentCenterX webView.y = posY webView.anchorY = 0 webView:request(filename, system.TemporaryDirectory) webView:addEventListener( "urlRequest", webListener ) end function webListener(event) local url = event.url or nil if not ( string.find(url, filename )) and url then print("url: ".. url) create\_webView() system.openURL(url) end return true end create\_webView()
even if you can catch the url from the webview it will still open it inside the webview so i had to remove the webview and created again. this way it prevents to change to the new link. the new link is opened outside the app. this way the app only shows your intended video, it still gives the ability to full screen the video or see it outside the app in youtube webpage.
if you only want to show youtube videos without the ability to go outside your app you need to go with @sphere suggestion. it works. i tried with the code i provided and worked fine it a little changes.
thank both