IAN LANG ELECTRONICS

Radio_Phone

android
radioicon

This is one of our experimental apps for capturing radio broadcasts in the UK and it does it in two ways. You can get the app from the Play Store (see the button on the left) and the project file (App Inventor 2) from the Dropbox site (another button on the left).

What's the rationale here? I'll tell you. Pull up a chair and a cuppa (pour me one whllst you're at it, will you please?) and let's begin.

The above button allows a direct download of the AI2 project file (.aia)

Once upon a time there were only two ways the general public could receive radio broadcasts. There was AM (amplitude modulation) which was never very clear but did it's job, and FM which was super clear but needed acres of spectrum space. AM could be broadcast over very long distances, FM over shorter ones.Then came digital radio. When they first advertised digital radio you'd have thought, from the hoo-ha, that the waters of the mississipi would flow backwards, statues would weep blood, everybody would become immortal and that Jesus himself was returning imminently but was just having a cigarette before he started. Those of us who knew a bit went "hmmmmmm..........."

breaktime

Over on the left there you can see the interface I made on a Tesco Hudl. The top four activate chrome, which in turn activates Radio Player. The below is what happens if I press Classic FM:

hudlradiophone
screenshotclassicfm

And as you can see what it does is to bring up in Chrome the radio player. So all the hard work is done there and in AI2 all we need to do is the following:

classicfmcodeblocks

Well, actually that isn't all we need to do because the purple bit at the bottom named "player" is in fact a procedure that is called every time a button is clicked.

If you don't know procedures are blocks of code that are used lots of times in the same programby different bits of that program. They're also known as subroutines. Every high level language has them and to get them to go there is a keyword: in this case it's call, but in other languages you may see GOSUB, and in C you set them up as functions and call them from the main loop , for example:

keyDown(Robot.keyboardRead());

which is an Arduino example. Let's have a look at what that procedure does:

playerblocks

Alrighty then it's down to the activity starter (AS). To get the AS to do anything, first of all you have to give it something to do. In this case it's android.intent.action.VIEW which in plain English means you want to use an in-built Android action which is VIEW. VIEW simply means "go on the internet" . Once it's on the internet it needs something to look at (or in this case an audio file) and so the next block down tells it where we want to go. If you look back at the Classic FM blocks you'll see I gave the variable a URL to go to and that's what this procedure will read. The URL in question was

http://www.classicfm.com/radio/player/?rpSt=classicfm&rpSrp=1.0

http is hypertext transfer protocol which gives the AS a clue it's a webpage, so it starts up chrome and shows me the page. Nice. Actually the first time it gave me a choice of browsers, Puffin or Chrome, since I have Puffin installed too. So I just told it always to use Chrome and off it went. (Puffin is a tad slower than Chrome for this game but I have Puffin because it can do Flash whilst Chrome can't.)

If you try this method with the BBC streams it wants to send you to the media player and does not always work. Besides that it's clunky. So we want to start VLC when a BBC stream is required and let VLC play it. All of the code-blocks behind the buttons work in just the same way so let's have a look at the one that does Radio 3: