📻 WebView Radio Stream Player

I was going to guess the font made the issue. Great detective work. I did not anticipate that. Need to place a caution in the write up letting others know with Android 9 and possibly lower coders need to use the default fonts. :cry:

Is this what you are talking about https://www.instructables.com/Internet-Radio-Using-an-ESP32/ .

Sure. The Radio Stream player code is for everyone to experiment. I am trying to produce something that is stable and that a visually impaired individual could actually use.

1 Like

I'm aware of all the ways to keep the screen alive. Having published numerous apps in the Play Store (Android) and App Store (iOS) for more than 10 years, I know very well how users react to such KeepScreenOn variants.

It shouldn't be a coincidence that almost everything has been done on both Android and iOS in recent years to reduce battery consumption (on Android, e.g. since API 23 through the introduction of the Doze mode). In this respect, the only option left is to use a Foreground service (at least with Android on devices with API 23+).

Yes, the battery is still a problem in new devices. The development of the battery does not keep up with the development of technology. In the past, an 800mAh battery lasted several days in phones, now 5Ah is not enough ... and we know that a larger battery is a bigger, thicker and heavier device... That's why they come up with newer and newer optimizations for apps...

Similar design but by a different author. I found on github.

Here is your radio with search and favorites list.

RadioStreamVI_SR.aia (230.0 KB)

1 Like

Yes, in some instances this code works
unrecoverable

except when the WebView displays this rotating icon .


When that spinning icon appears the only solution is to close the app and restart.

Any ideas? I will continue to experiment and try to trap the error message associated with the failure.

Perhaps this for errors?

image

Also, this seems to work well using the native webviewer, what is the need for CustomWebview? (although nothing wrong with using it :wink: )

Nice idea but using it refused to identify any errors I was getting. I tried the CustomWebView and it works to find errors.

Later today I will try your method of restart. Thanks

The only problem is that at this point when playback stops, CustomWebView doesn't return any error. He just freezes. I haven't noticed any dependencies either. I tried different streams mp3, aac, with different bitrates and the error occurs randomly.

Maybe it will be more stable just with some player. where you will also get metadata with the title of the song being played. I don't know if it makes sense to break down doors that are open.

It doesn't matter what audio format is used. The stream breaks off after a few minutes (~3-6 min randomly) in idle mode. I tested it (years ago) intensively and extensively on all AI2 distros. Doze mode shuts down all possible functions after a while to save battery power.

Again, the only way to avoid the problem is to use a Foreground service (at least if the app is going to be published on the Play Store; otherwise, there is a workaround).

It's not about idleness. We're talking about another bug, when switching streams sometimes some streams stop the player and then no other stream can be played. it's like webview is hanging... Then you have to turn the app off and on again. But later on the same link works that previously failed...

For that matter, I'm already experimenting with the Itoo extension, and your ActivityLifecycle. Is there any extension you recommend for the Foreground service?
I also made an extension that fetches Metadata from the url link, useful when using a WebView instead of a player.

It may be because it takes some time to buffer.

Taifun

2 Likes

Tried using open another screen screenName Block as you suggested. Unfortunately it does not unlock the Custom Web Viewer. Interesting potential work around but it is not a solution. Thanks

Can you make the webview freeze on demand, I have not had it freeze on me yet?

I'm having this bug too. And it cannot be done by demand. You can try changing the stream often.

Congratulations.
I've done a radio app before. You can update the radio list via google drive. No problem so far though
The radio was a problem when the phone rang. You had to turn off the radio. That's why I added dialing blocks. If a call comes in, the radio is switched to mute. After the call ends, the radio starts playing again.
I was making it keep playing with the clock block in the background.
Maybe you can add something like this.
I would recommend.

Be good if you could show your blocks coding for this, so that others can learn....

It might be worth a try creating an html file to play back the audio streams, then you could use javascript to detect/handle any errors in the playback stream....

Regarding a foreground service

I modified Ullis' Keep Alive Service example as follows .

The code plays a single radio stream in excess of 45 minutes in the foreground while allowing you to use other apps concurrently.

I will clean up this example up and integrate KAS into a version of Radio Stream Player later today or tomorrow (unless someone else post a more detailed example first) that supports doze mode. Be aware, like a Stay Awake routine, KAS eats battery energy.

Tested on an Android 13 Samsung A13. Played the stream continuously for over 45 minutes (when I stopped testing) while allowing a phone call and use of other apps while streaming. :astonished:

This is how I used phone call blocks in my radio show.
My app used to work better. It even worked on Android 2.4 version.
But it started to cause problems in higher versions. I did not fix the program afterwards. I am doing the update from a file on google drive.
I haven't updated my radio app because of this.
I moved it to the internet.
It can be listened through the internet browser.
www.mikrobotikradyo.tk

image

MY source code :
SAFAK_RADIO_V3.aia (203.9 KB)

1 Like