Skip to main content

Playing Android device audio on macOS

ยท 3 min read

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.
  • adb installed and usable. To install, run brew install android-platform-tools
  • VLC installed in your /Applications folder: 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, and
      • sudo mv ~/Downloads/sndcpy/sndcpy.apk /usr/local/bin
    • This APK is installed to your android device whenever you run sndcpy
  • Create a script called vlc in /usr/local/bin by running sudo 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/bin is that your mac will instantly be able to use it like a command, by calling vlc (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 ~/.zshrc so that sndcpy can 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 sndcpy in terminal