Stream media from link within WebView

cbanks

Active Member
Licensed User
Longtime User
What is the code to stream audio by clicking on a link in a WebView? I put in the a href to the audio but it doesn't do anything when clicking on the link. Thanks.
 

cbanks

Active Member
Licensed User
Longtime User
Thanks, that was very helpful.

What code needs to be added so that the mp3 will still play when the screen turns off?
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Look at the modification I've made.

If you press the HOME key it will continue playing in the background, press the BACK key and the app will exit and will stop playing.
 

Attachments

  • Sample.zip
    6.7 KB · Views: 439
Upvote 0

saidgta

New Member
please help me

first,excuse me 4 bad english.

i need your help,pleaaaaase help meeee!
this sample that you attached,is for streaming audio.
now i designed a html file with an internal audio mp3 file.
now i want when i click on "play song" in webview , player play the internall html song, no online url.
pleaaase help me.

i used thease codes,but dont play audio:


'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 Player 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 WebView1 As WebView

End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Main")

Player.Initialize("Player")

WebView1.LoadUrl("file:///android_asset/index.html")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)

'If the user presses the HOME or BACK buttons stop the payback

Player.Stop

End Sub

'#######################
'######## Views ########
'#######################

Sub WebView1_OverrideUrl(Url As String) As Boolean

'This SUB will grab the link the user clicked on and save it in URL

Player.Load(Url)

End Sub

'#################################
'######## Player routines ########
'#################################

Sub Player_StreamReady

'Stream ready to play

Player.Play

ToastMessageShow("Playing track", False)

End Sub

Sub Player_StreamError(ErrorCode As String, ExtraData As Int)

ToastMessageShow("Player Error: " & ErrorCode & ", " & ExtraData, True)

End Sub

Sub Player_StreamBuffer(Percentage As Int)

End Sub
 
Upvote 0
Top