We are going to create a streaming radio player that never stops unless we press "Stop", taking advantage of the possibilities offered by the Itoo Extension
For this we will use the following components
When you start the app with Web1.Get, it will download a radio list in m3u8 format, from which we will extract the title data of the radio station and its link (in this case it is a list of Spanish streaming radios).
You can see the process of extracting data and presenting it in a Listview in the .aia file since the purpose of this tutorial is how to use the service so that streaming playback does not stop.
Part of the activity
play
- When you press the Play button, check that a station has previously been selected in the listview
- It is verified that the service is stopped
- Later we create the shared variable "radio", where we store the link of the station
- The service starts with the notification with the title "Play Radio" and subtitle the name of the station, the "radia" procedure starts.
Pause
By pressing the Pause button it is checked whether it is already active or not, if it is active we create the shared variable "resume" as true, if it is not active we create the shared variable "pause" as true
Stop
By pressing the button, do the following:
- Shared variable "pause" to false
- Shared variable "resume" to false
- Shared variable "stop" to true
Part of the service
radia
- We initialize the Clock1 and Player1 components
- Player source, the one indicated in the shared variable "radio"
- We start the player
- We register the Clock1.Timer eventor with the "data" procedure
data
- If the shared variable "pause" is true, we pause the player and declare the shared variable "pause" to false
- If the shared variable "resume" is true, we set the player to start and declare the shared variable "resume" to false
- If the shared variable "stop" is true, we stop the player, we declare the shared variable "stop" to false, we stop the clock and the service.
Don't forget if your mobile is a Xiaomi or Samsung, set the battery saving to "No Restrictions"
Un saludo
radioweb.aia (79,5 KB)