Android Question webview and html

Almora

Well-Known Member
Licensed User
Longtime User
<HTML><HEAD>
<TITLE>test</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<style type="text/css">.style12 { color: #FFFFFF; font-weight: bold;}</style>
</HEAD>
<BODY leftMargin=0 topMargin=0 bgcolor="#eeeeee">
<center>
<table width="671" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#000099">
<tr><td width="671"><div align="center" class="style12">test</div></td></tr>
</table>
<script src="//play.player.im/player/playlist.php?uid=525"></script>
</center> </BODY></HTML>

hi..
I can't show this code on webview.
How can I show with webview?
the code i use

B4X:
   .....
  WebView1.Initialize("")
  WebViewExtras1.Initialize(WebView1)
  Dim WebChromeClient1 As DefaultWebChromeClient
  WebChromeClient1.Initialize("WebChromeClient1") 
   WebViewExtras1.SetWebChromeClient(WebChromeClient1)

'WebViewExtras1.LoadHtml("")
WebView1.LoadHtml($"<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type='text/javascript' src='//play.player.im/player/playlist.php?uid=525'></script>
</head>
<body>
</body>
</html>"$)
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
first, your src='' is illegal. protocol missing. webview doesn't know what you want (http, https, etc)
and even after you add the protocol, you trigger a cors violation.
i gather you want to play music or some medi, but you can't do it like you're doing.
you should try to run your html in chrome on your desktop and then look at the developer's tab. you'll see exactly what the error is.
webview is not chrome. some things that work in chrome do not work in webview.
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
src='' is illegal. protocol missing. webview doesn't know what you want (http, https, etc)
I have tried them. but I could not open it.
I can open the code in the online compiler. here
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Have you tried set JavaScriptEnabled to True ?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Have you checked this post?
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
test.html
as I added to assets. but yime did not succeed.
I am trying it in Quickedit+.apk text editor, it opens very well.
 

Attachments

  • Screenshot_20210303-123011_QuickEdit+.jpg
    223.1 KB · Views: 250
  • PicsArt_03-03-12.32.04.jpg
    146.8 KB · Views: 222
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
I afraid the content is blocked due to cross origin.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Can you open the html file from windows desktop?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
no
but it works in online preview
What do you mean by online preview?

I can’t open the page maybe due to different country or cross origin reason.

Do you manage to show if using iframe tag?
 
Upvote 0

sfsameer

Well-Known Member
Licensed User
Longtime User
I don't think this is related to the webview, i have put your script in a normal HTML file and opened it using google chrome on the PC and here are the results :

All the results have failed, meaning either the URL you are reading from is validating the incoming connection and refusing to show the data unless it's authenticated or it should be embedded in a player plugin called (jwplayer) :

*The above picture is from the source code of the java script that is being called : http://play.player.im/player/playlist.php?uid=525&sid=885

Which you can find the jwplayer control here : https://www.jwplayer.com/


 
Upvote 0

sfsameer

Well-Known Member
Licensed User
Longtime User
Great news!
After alooot of testing, we have uploaded the html file to our website :
http://b4xcode.com/test3.html *this url will be deleted after 30 minutes

and it works! why? because the plugin (jwplayer) requires to be uploaded and not viewed locally (from PC)

So in short, upload it to a free web hosting and create a webview and put the link in the URL and you are good to go
also make sure you have enabled the javascript : wv1.JavaScriptEnabled = True

*Keep in mind that this streaming service is veeeeery slow so it will take about 10 minutes until it loads fully.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…