Page 1 of 1

Need a tutorial for Building a simple web browser for Androi

Posted: Sun Jun 14, 2015 5:53 pm
by DR White
Where can I find a tutorial for “Building a simple web browser for an Android platform”?

I was given a great start with the code below, but on android phones, when I play a mp3 file the screen goes black:

--------------------------------
local sBrowserId,sPlayerId

on preOpenCard

//check to make sure you're in the mobile environment

if the environment is "mobile" then

//set up native player named "SermonPlayer" and use mobilecontrolset to set it's visiblity,rect. etc

mobileControlCreate "player", "SermonPlayer"
put the result into sPlayerId
mobileControlSet sPlayerId, "visible","true"

//I used a grouped rectangle named "PlayerArea" to define the rect of my player

mobileControlSet sPlayerId, "rect", (the rect of grc "PlayerArea")
mobilecontrolset sPlayerId,"Showcontroller","true"
--mobileControlSet sPlayerId, "filename", "http://spokenwordchurch.com/mp3sermons/ ... School.mp3"

//Use the Mobilecontroldo command to play,stop, or pause the player

--mobileControlDo sPlayerId, "play"

//set up native browser set it's rect visibility and URL with mobilecontrolset
mobileControlCreate "browser"
put the result into sBrowserId
mobileControlSet sBrowserId, "rect", the rect of group "Browser"
mobileControlSet sBrowserId, "visible", "true"
mobileControlSet sBrowserId, "url", " http://covingtongoodnews.com/audio-downloads/"

//if the environment is not mobile then exit the handler
else
exit preopencard
end if

end preOpenCard

on browserStartedLoading pUrl

//when the browser tries to load a URL, if it is an MP3, then use the mobilecontrolset command to laod it into the player
if char -4 to -1 of pUrl = ".mp3" then


mobileControlSet sPlayerId, "filename", pURL

//use the mobilecontroldo command to start playback

mobileControlDo sPlayerId, "play"

mobileControlSet sPlayerId, "visible", "true"

end if
end browserStartedLoading

//Delete Mobile Controls using mobilecontroldelete command
on closeCard
if the environment is "mobile" then
mobileControlDelete sBrowserId
mobileControlDelete sPlayerId
end if

------------------------------------------------
Thanks,

David

Re: Need a tutorial for Building a simple web browser for An

Posted: Mon Jun 15, 2015 3:27 pm
by LCNeil
Hi David, there is a space in your browser URL that is causing the issue

Code: Select all

mobileControlSet sBrowserId, "url", " http://covingtongoodnews.com/audio-downloads/"
also, for some reason, I was experiencing a crash with the initial URL in the script. If you experience a crash after removing the space, please use the following as this should resolve the issue-

Code: Select all

mobileControlSet sBrowserId, "url", "http://covingtongoodnews.com/audio-downloads/"
I would also use "browserLoadRequested" instead of "browserStartedLoading" as this will return the correct url when the user click on a mp3 link

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
-