I recently needed to show some photos and videos on my phone on a screen. In the past, I used the youtube app to “cast” a video on my TV. However, this time it was different
- I needed to show videos on my phone’s gallery
- The screen I was casting to was not a “smart” one - that is, it did not support screen mirroring technologies such as Airplay, Chromecast or Miracast, etc
After some googling, I found some software but they were not free and some didn’t support embedded Linux devices such as the Raspberry Pi.
I own an iPhone and as far as I know, iOS devices do not support screen mirroring over Chromecast natively. iOS and macOS devices support screen mirroring natively via Airplay. Luckily, there is RpiPlay which is an open-source AirPlay mirroring server for the Raspberry Pi.
Compiling RpiPlay was quite straightforward. The README has clear instructions and some tips on how to optimise for performance.
- RpiPlay requires VideoCore userspace libraries since it uses Broadcom’s OpenMAX stack as present in
/opt/vcin Raspbian. Despite using the raspbian base image, these libraries were not present.
ilclientcan be downloaded from Raspberry Pi’s firmware repo or downloaded from raspbian sources. The library sources exist as examples and they are provided by the
- When RpiPlay runs, it advertises a device name which is configurable. Under the hood, it uses avahi to do this. Avahi already runs in the hostOS so for it to work, we can allow the container to use the avahi daemon via dbus. It simply required adding the dbus label and environment variable pointing to the dbus socket. This is explained in the docs
You can take a look at the app here : https://github.com/rahul-thakoor/air-pi-play
Running this app is as simple as deploying it to a balenaCloud fleet. You can do it in just one click by using the button below:
- iOS or macOS device capable of casting over Airplay
- A Raspberry Pi - this project supports the Pi Zero but YMMV
- Of course, an external screen, tv or projector to share to
- Make sure audio works over hdmi
- Try to make app generic by compiling with gstreamer support - right now the app uses Raspberry Pi specific libraries.
- Optimise the app size for the edge - the current size is ~ 500 MB!
This app would not be possible without RpiPlay