Child-Friendly Media Player

The Problem

I have a kid. She likes watching shows. Those shows are not necessarily easy to play to a screen without controlling the system through a phone/tablet/whatever. I want to give her autonomy over choosing what to watch during her allowed time without giving her a second, smaller screen to control the bigger screen.

We discussed a DVD player, but DVDs are slow, menus are awkward, and DVDs are notoriously easy for kids to destroy. We also ran into the issue of a lot of shows or movies not being on physical media.

I was looking for a solution that had these requirements:

  • Whitelist for allowed media
  • Controllable by a child
  • Withstand use by a child
  • No menu navigation
  • Easily add or remove content (as shows get new episodes or we get new movies)

After dozens of seconds of searching for a solution, I decided to make my own.

player

The Solution

The core solution was based on a NFC Hat for a raspberry pi, a big pile of 25mm circle NFC tags, and some sticker paper.

We went to the library with some sticker paper and a bunch of images on a thumb drive and used their sticker-making software to print out two stickers for each show and attached them to tokens at random. tokens

After putting the stickers on the tokens, I used the demo software that came with the NFC Hat to get the token UID for each one and noted down which token ID went with which show. I put the UIDs into a config file along with either a network folder, a PBS Kids show slug, or a direct link to a file.

The Technical Bits

The shows and movies that we wanted available break down into three categories:

  • PBS Kids shows that are still on the air
  • PBS shows that are off air
  • Movies that we’ve ripped onto a local server

PBS Kids API

For the first (and most important) category, we need to take a look at the PBS Kids API. You can access a list of currently running shows using their show-tracking endpoint. That endpoint will show you a blob of JSON that contains the title and a “slug” for each show. Take that slug and swap it into the shows parameter on their show-list endpoint and you can see the list of available episodes for a given show.

Some example python to grab a video link for a given stub:

def get_url(stub):
    url = f"https://producerplayer.services.pbskids.org/show-list?shows={stub}&page=1&page_size=50&available=public&type=full_length"
    response = requests.get(url).json()
    randomepisodenumber = random.randint(0,len(response["items"])-1)
    episodeurl=response["items"][randomepisodenumber]["videos"][0]["url"]
    return episodeurl

Off-Air PBS shows

We have plenty of off-air PBS shows, too. Wishbone, Magic School Bus, Between the Lions, etc. For these shows, I have a network location set as the matching configuration and do a walk of the directory and pick a random episode from the pile.

if(os.path.isdir({path from config})):
    files = [os.path.join(path, filename)
        for path, dirs, files in os.walk({path from config})
        for filename in files
        if filename.endswith(".mp4") or filename.endswith(".m4v")]
    return random.choice(files)

Local Movies

This one is pretty straightforward, if the mapping config file links to a specific file, just play the specific file

if(os.path.isfile({path from config})):
    return {path from config}