WebView Not Loading Website

Nyptop

Active Member
Licensed User
Longtime User
Hi Again,

I'm having an issue with getting the webview here to load the given URL's. I have checked my connectivity and it worked perfectly on my device. However, when I try to load the page on my phone via the app it does not work.

I have a suspicion that it may have something to do with the fact that you cannot view mp3 player pages on android devices (or mine at least)

Something may be astray with the code, thus I have posted it here if you think it may be the source of my problems.

Thanks,

Neil

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim ScrollView1 As ScrollView
   Dim button1, button2, button3, button4, button6 As Button
   Dim WebView1 As WebView
   Dim Back As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
   activity.LoadLayout ("SoundClips.bal")
   ScrollView1.Panel.LoadLayout("SoundClipsPanel.bal")
   WebView1.LoadUrl("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   Button6.Text = Button1.Text
End Sub
Sub Back_click
   StartActivity("main")
End Sub
Sub Button1_click
   Button6.Text = Button1.Text
   WebView1.LoadUrl ("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
End Sub
Sub Button2_click
   Button6.Text = Button2.Text
   WebView1.LoadUrl ("www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
End Sub
Sub Button3_click
   Button6.Text = Button3.Text
   WebView1.LoadUrl ("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
End Sub
Sub Button4_click
   Button6.Text = Button4.Text
   WebView1.LoadUrl ("llnw.libsyn.com/p/3/3/5/3350e82742daf08b/vivaldi_bassonconcertoaminor.mp3?s=1339059621&e=1339060498&c_id=1789250&h=6b4d7cabf4ec429149cdafbbb7c3611e")
End Sub
 

Nyptop

Active Member
Licensed User
Longtime User
Ok I'm still having problems.

The image attached shows the two errors I get. (After clicking a button the one on the right appears first followed by the error on the left).

Here is the updated code:

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim mp, mp1, mp2, mp3 As MediaPlayerStream
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim ScrollView1 As ScrollView
   Dim button1, button2, button3, button4, button6 As Button
   Dim Back As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
     If FirstTime Then
        mp.Initialize("mp")
      mp1.Initialize("mp1")
      mp2.Initialize("mp2")
      mp3.Initialize("mp3")
    End If
    mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   mp.Play
   activity.LoadLayout ("SoundClips.bal")
   ScrollView1.Panel.LoadLayout("SoundClipsPanel.bal")
   Button6.Text = Button1.Text
End Sub
Sub Back_click
   StartActivity("main")
End Sub
Sub Button1_click
   Button6.Text = Button1.Text
   If mp1.IsPlaying Then
   mp1.Stop
   mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   mp.Play
   Else If mp2.IsPlaying Then
   mp2.Stop
   mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   mp.Play
   Else If mp3.IsPlaying Then
   mp3.Stop
   mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   mp.Play
   Else
   mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
   mp.Play
   End If
End Sub
Sub Button2_click
   Button6.Text = Button2.Text
   If mp.IsPlaying Then
   mp.Stop
   mp1.Load("www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
   mp1.Play
   Else If mp2.IsPlaying Then
   mp2.Stop
   mp1.Load("www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
   mp1.Play
   Else If mp3.IsPlaying Then
   mp3.Stop
   mp1.Load("www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
   mp1.Play
   Else
   mp1.Load("www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
   mp1.Play
   End If
End Sub
Sub Button3_click
   Button6.Text = Button3.Text
   If mp.IsPlaying Then
   mp.Stop
   mp2.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp2.Play
   Else If mp1.IsPlaying Then
   mp1.Stop
   mp2.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp2.Play
   Else If mp3.IsPlaying Then
   mp3.Stop
   mp2.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp2.Play
   Else
   mp2.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp2.Play
   End If
End Sub
Sub Button4_click
   Button6.Text = Button4.Text
   If mp.IsPlaying Then
   mp.Stop
   mp3.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp3.Play
   Else If mp1.IsPlaying Then
   mp1.Stop
   mp3.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp3.Play
   Else If mp2.IsPlaying Then
   mp2.Stop
   mp3.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp3.Play
   Else
   mp3.Load("music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
   mp3.Play
   End If
End Sub
Sub mp_StreamReady
    Log("starts playing")
    mp.Play
End Sub
Sub mp_StreamError (ErrorCode As String, ExtraData As Int)
    Log("Error: " & ErrorCode & ", " & ExtraData)
    ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub
Sub mp_StreamBuffer(Percentage As Int)
    Log(Percentage)
End Sub
 

Attachments

  • error2.jpg
    error2.jpg
    39.6 KB · Views: 259
Upvote 0

pluton

Active Member
Licensed User
Longtime User
Try like this. This is only sample but you can do with your files. Here is a little mp3 file because it is boring for me to download your whole mp3 of 4 Mb :)

B4X:
Sub Button1_click
'ToastMessageShow("Loading mp3...wait",False) 'show loading mp3 or you can use progressdialog
ProgressDialogShow("Loading mp3...please wait")
mp.Load("http://www.noiseaddicts.com/samples/4162.mp3") 'downloading mp3
End Sub
Sub mp_StreamReady
ProgressDialogHide 'mp3 has finish downloading and is ready to start playing
    ToastMessageShow("Ready to play", True)
    Log("starts playing")
    mp.Play 'start to play
End Sub
Sub mp_StreamError (ErrorCode As String, ExtraData As Int)
    Log("Error: " & ErrorCode & ", " & ExtraData)
    ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub

BTW
This Your Button1_click I will do like this:

B4X:
Sub Button1_click

    Button6.Text = Button1.Text
' your check if someone of mp1, mp2 or mp3 is playing and If does stop them
If mp1.IsPlaying Then
    mp1.Stop
End If
If mp2.IsPlaying Then
    mp2.Stop
End If
If mp3.IsPlaying Then
    mp3.Stop
End If

'call only once here to play. Not need to call it every if check
mp.Load("www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
ProgressDialogShow("Loading mp3...please wait")

'mp.Play -not here this play
End Sub

'This mp.Play put only play after your mp3 has downloaded
' so you must it put in StreamReady

Sub mp_StreamReady
ProgressDialogHide
mp.Play 

End Sub
 
Last edited:
Upvote 0

Nyptop

Active Member
Licensed User
Longtime User
Thanks Pluton,

this has been a great help :) I'm wondering whether you may know of anything on B4A that works like your typical audio player i.e loading part of the song then playing whilst the rest loads?

Thanks again,

Neil
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
Thanks Pluton,

this has been a great help :) I'm wondering whether you may know of anything on B4A that works like your typical audio player i.e loading part of the song then playing whilst the rest loads?
Thanks again,

Neil

You mean streaming like on youtube. It plays while rest of loading.

This is how plays file with intents (your default player)
It is playing while the rest is loading but you want something that will play in your application

Code like this:
B4X:
Sub Button2_Click

Dim i As Intent
i.Initialize(i.ACTION_VIEW, "http://www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
i.SetType("audio/*")
StartActivity(i)

End Sub

Screenshots:
image.png
image.png
image.png


Or you can try with some of libraries here on B4A forum.
 
Last edited:
Upvote 0

Nyptop

Active Member
Licensed User
Longtime User
Wow thanks!

I'm afraid I still have problems :(

It (the audio/* streamer thing) works fine with button1 but doesn't work with any of the other buttons:

B4X:
Sub Button1_click
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "http://www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
i.SetType("audio/*")
StartActivity(i)

End Sub
Sub Button2_click
Dim a As Intent
a.Initialize(a.ACTION_VIEW, "www.robertronnes.com/GiorgioPacchioniItalianComposer/Pacchioniconcertoperfagotto.1movt.mp3")
a.SetType("audio/*")
StartActivity(a)

End Sub
Sub Button3_click
Dim b As Intent
b.Initialize(b.ACTION_VIEW, "music.ibiblio.org/pub/multimedia/pandora/mp3/bassoon/Arthur_Grossman_Live/Saint-Saens.mp3")
b.SetType("audio/*")
StartActivity(b)

End Sub
Sub Button4_click
   Dim s As Intent
s.Initialize(s.ACTION_VIEW, "http://music.ibiblio.org/pub/multimedia/pandora/vorbis/contrib/Bassoonia/1Weissenborn.ogg")
s.SetType("audio/*")
StartActivity(s)

End Sub

Also, once the Mp3 streamer opens I can't find a way to close it :L

Thanks for the excellent help so far!

Neil
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
No problem Neil

Here is excellent example for you.
Look at atachment

Use VideoView. It can stream audio and play it while the rest is loading and it doesn't use device player and doesn't exit your app.

Here is sample for one button and you can manage the rest :sign0060:
Try this

B4X:
Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("test")
vv.Initialize("vv")
Activity.AddView(vv,0,310,320,110) 'you can also hide this
vv.Color = Colors.Blue 'this is only to show where is vv :)

End Sub

Sub Button1_click

If vv.IsPlaying = False Then
vv.LoadVideo("http","http://www.robertronnes.com/mybassoonrepertoire/BachPartita1movtAllemande.mp3")
vv.Play
button1.Text = "Stop Playing"
Else
vv.Stop
button1.Text = "Play"
End If

End Sub

lala.png
 

Attachments

  • Audio_Stream_VideoView.zip
    6.8 KB · Views: 262
Last edited:
Upvote 0

Nyptop

Active Member
Licensed User
Longtime User
This is brilliant! I'll let you know when the app is finished!

For me the .OGG file still did work!?!

Once again thanks!

Neil
 
Upvote 0
Top