Android Question why i can't play mp3 from url ?

王安邦

Member
Licensed User
Longtime User
http://203.64.253.13/cherry.mp3--> this url is correct
when i run the following code, i got two problems :
1. File.Exists("http",http://203.64.253.13/cherry.mp3) --> result is false
2. i can't play the audio file:cherry.mp3
Any help will be highly appreciated !

mp.Initialize2("mp")
mps.Initialize("mps")
If File.Exists("http","http://203.64.253.13/cherry.mp3") Then
'mps.Load("http://203.64.253.13/cherry.mp3" )
mp.Load( "http","http://203.64.253.13/cherry.mp3" )
lbStat.Text="選取播放的音樂為:" & CRLF & _
"來自網站資源" & CRLF & _
"http://203.64.253.13/cherry.mp3"
rb1.Checked=False
'mps.Play
mp.Play
Else
ToastMessageShow( _
"網路不通或欲播放的cherry.mp3 檔案不存在 !",False)
End If
 

sorex

Expert
Licensed User
Longtime User
I doubt file.exist will work for webbased stuff but only for the local file system and maybe smb.

Does it pass the if statement?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, with this it plays.

you forgot to add the play in the right event.


B4X:
Sub Activity_Create(FirstTime As Boolean)
mp.Initialize("mp")
mp.Load("http://203.64.253.13/cherry.mp3")
End Sub

Sub mp_StreamReady
  mp.Play
End Sub
 
Upvote 0

王安邦

Member
Licensed User
Longtime User
ok, with this it plays.

you forgot to add the play in the right event.


B4X:
Sub Activity_Create(FirstTime As Boolean)
mp.Initialize("mp")
mp.Load("http://203.64.253.13/cherry.mp3")
End Sub
 
Sub mp_StreamReady
  mp.Play
End Sub

Thank for your help, The problem is already solved ! highly appreciated !
 
Last edited:
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
ok, with this it plays.

you forgot to add the play in the right event.


B4X:
Sub Activity_Create(FirstTime As Boolean)
mp.Initialize("mp")
mp.Load("http://203.64.253.13/cherry.mp3")
End Sub

Sub mp_StreamReady
  mp.Play
End Sub



can be download it using url ?
 
Upvote 0
Top