Playing Android device audio on macOS
Why?
Update: scrcpy 2.0+ supports Audio forwarding. You don’t need sndcpy anymore. Thanks Romain Vimont.
I want to listen to the instructor playing on an Android app (Fiit) on my speakers which are connected to my MacBook. I am already sharing the screen of my Android on my MacBook by using scrcpy, a tool by Romain Vimont. sndcpy lets us to do this, also a tool made by Romain Vimont. The naming of these tools were inspired by C library function, strcpy, which copies strings between memory locations.
You want to play music or app sounds on your Android device on your macOS, and
- You are displaying your Android screen on the mac already, but you want sound too
- Your Android device doesn’t have an audio jack
- Your speakers aren’t bluetooth
- You don’t want to use your headphones
- I do not want to sweat onto my headphones, or
- I want to share my music with others
- Your macOS is connected via AUX cable (or USB-C/HDMI) to speakers, so let’s use them instead
Pre-requisites
- Command line experience, or just being resourceful.
adbinstalled and usable. To install, runbrew install android-platform-tools- VLC installed in your
/Applicationsfolder: https://www.videolan.org/vlc/ - Open Terminal.app (already installed at
/Applications/Utilities.Terminal.app) or iterm2
Installation steps
-
Download the sndcpy APK and script from rom1v/sndcpy on GitHub, and place them in
/usr/local/bin- Unzip the file downloaded from Github and move them using
sudo mv ~/Downloads/sndcpy/sndcpy /usr/local/bin, andsudo mv ~/Downloads/sndcpy/sndcpy.apk /usr/local/bin
- This APK is installed to your android device whenever you run
sndcpy
- Unzip the file downloaded from Github and move them using
-
Create a script called
vlcin/usr/local/binby runningsudo vim /usr/local/bin/vlc, and passing the following content:-
/Applications/VLC.app/Contents/MacOS/VLC -I rc "$@" -
The reason we put it in
/usr/local/binis that your mac will instantly be able to use it like a command, by callingvlc(once you restart the shell 🐚). -
Optional: Confirm the file contains those contents, by running
cat /usr/local/bin/vlc
-
-
Make the file executable to you and the group:
sudo chmod 755 /usr/local/bin/vlc -
Add the following to your
~/.zshrcso thatsndcpycan get the APK whenever it wants to install it onto your device:-
export SNDCPY_APK=/usr/local/bin/sndcpy.apk
-
-
Restart your shell, or reload that file:
source ~/.zshrc
Usage steps
- Connect android device to computer (or attach it remotely via adb)
- Run
sndcpyin terminal