B4J Question [B4J] Internet Radio

mading1309

Member
Licensed User
Longtime User
I am looking for a solution to use of MP3 or ACC streams with B4J, for example listen to Internet Radio stations
Mediaplayer does not work for some reason. The Internet connection is slowly but good enough to listen to Internet Radio stations on Android devices
Any working proposal to listen to MP3 or ACC streams under slowly Internet condition using B4J?
Thanks in advance
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The stream is probably not supported by MediaPlayer. This url for example does work:
B4X:
Dim mp As MediaPlayer
mp.Initialize("mp", "http://icecast.unitedradio.it/Radio105.mp3")
mp.Play

A different option, which I haven't tried it myself, is to download ffplay and play it with jShell: https://github.com/BtbN/FFmpeg-Builds/releases
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i fed a list of .mp3 streaming sources that i use daily with b4a to the b4j mediaplayer. all connected without issue, but almost all disconnected within a second or two. the ones that did not connect streamed fine. so, there seems to be an issue with mediaplayer under b4j. i tried both W7 and W10 and jdk 8.xxx. i should mention that, occasionally, some streams which disconnected were able to stream if i kept starting the app over and over.

i had better luck with a webview. you get a nice little "radio view", and the streams which disconnected via mediaplayer, streamed fine with webview's html5 features (ie, <audio>). note: if you go this way, don't be surprised if you have to manually click on the play icon. google has turned off the autoplay feature. you can add the autoplay attribute, but it may not work. i had no cases of disconnect with the webview.

a final comment, you're not going to write a better streaming app than vlc yourself. you can run vlc through your b4j app via sh. sometimes you have to go with the flow.
 
Upvote 0

alas

Member
i tried it

play radio:
    Dim mp As MediaPlayer
    mp.Initialize("mp", "https://montecarlodoualiya128k.ice.infomaniak.ch/mc-doualiya.mp3")
    mp.Play
 
Upvote 0

udg

Expert
Licensed User
Longtime User
@Erel : listen to this one..you won't learn Italian but some good music will spread throughout the house :)
B4X:
Dim mp As MediaPlayer
mp.Initialize("mp", "https://icy.unitedradio.it/um1026.mp3")
mp.Play

Ok, it's more "energy" rather than music but surely anything not properly anchored in your house is gonna rock out
1610384074095.png
 
Last edited:
Upvote 0

mading1309

Member
Licensed User
Longtime User
Hello to all
Thanks for the information
It seems it isn't possible for my internet performance here to find a solution
With an average of 8 kBytes/s audio streaming isn't a good idea.
Have to wait until the performance getting better
 
Upvote 0
Top