loading...
Cover image for Share your Android screen and audio on macOS

Share your Android screen and audio on macOS

equiman profile image Camilo Martinez ・4 min read

Forget it about Vysor, there is a better and FREE option to screencast your Android screen called scrcpy and sndcpy as a complement.

With both of them, you will can screencast your android mobile screen and also forward audio to your computer. Sadly they need to run separately.

Command Meaning
scrcpy Screen Copy
sndcpy Sound Copy

In this post, we are going to focus only on macOS devices, but you also can use it as a guide for Windows or Linux following the links on each project.

Prerequisites

Homebrew (Package Manager)

Brew it's a software repository and has his own classification. The inside brew can found the CLI app and utilities. Inside cask is all the application with Graphical Interface.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap homebrew/cask-fonts

brew update
brew upgrade
brew cleanup
https://brew.sh — usage: https://docs.brew.sh/FAQ

Run this command, and follow doctor recommendations:

brew doctor

Android Debug Bus (ADB)

You need adb, accessible from your PATH.

If you already have installed Android Studio it's most probably that you already have installed ADB.

brew cask install android-platform-tools

Check connection

To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options.

On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go to Settings -> About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.

Connect your Android device via USB, and run adb devices command to list available devices.

adb-devices

VideoLan

VLC the famous cross-platform multiplayer.

brew cask install vlc

Install scrcpy

This application provides display and control of Android devices connected on USB (or over TCP/IP). It does not require any root access. It works on GNU/Linux, Windows and macOS.

brew install scrcpy

Now you can run scrcpy command no mather the path where you are. It will mirror your mobile on your device. Press ctrl+c in the terminal to stop.

It's recommended to see the documentation to learn the keyboard shortcuts and other features.

Install sndcpy

This tool forwards audio from an Android 10 device to the computer. It does not require any root access. It works on GNU/Linux, Windows and macOS.

There is no brew formula available but we can download from GitHub and extract those files on the recommended path: ~/Applications/Android/snappy.

Alias

Assuming you have extracted files on recommended path, add this configurations on ~/.bash_profile and/or ~/.zshrc file:

export SNDCPY_HOME="$HOME/Applications/Android/sndcpy"
export SNDCPY_APK="$HOME/Applications/Android/sndcpy/sndcpy.apk"
export PATH="$SNDCPY_HOME/:$PATH"
alias sndcpy="sh sndcpy"

Update terminal source with this command source ~/.bash_profile or source ~/.zshrc to recognize new paths and aliases. Now you can run sndcpy command no mather the path where you are.

Pairing

It will install the app on the device, and request permission to start audio capture:

pairing

Once you clicked on START NOW, press Enter in the console to start playing on the computer. Press ctrl+c in the terminal to stop.

VLC may print this error message once:

main stream error: connection error: Connection refused

It is "expected", just ignore it. The sound continues to be played on the device. The volume can be adjusted independently on the device and on the computer.

Fusion

They need to run on an independent terminal. What if I teach you how to use the fusion technique with them?

fusion

It's time to convert scrcpy and sndcpy into scrsnd.

On the recommended sndcpy path create an empty file on called scrsnd.sh and set execution permissions with chmod +x scrsnd.sh. Leave empty by now.

And add this alias on ~/.bash_profile and/or ~/.zshrc file:

alias scrsnd="sh $SNDCPY_HOME/scrsnd.sh"

Update terminal source with this command source ~/.bash_profile or source ~/.zshrc to recognize new alias.

It's time to choose one of these roads: Terminal or iTerm.

Terminal

If you prefer to use the built-in Terminal app, add this code to scrsnd.sh file:

#!/bin/bash

osascript <<'END'
tell application "Terminal" to do script "sndcpy"
tell application "Terminal" to do script "scrcpy"
END

Run the scrsnd command and you will see that open two terminals, one with sndcpy and the other with scrcpy.

sndcpy

scrcpy

iTerm

That's my favorite because you can unleash all the power on a single terminal window.

goku

Add this code to scrsnd.sh file:

#!/bin/bash

osascript <<-EOF
    set cmds to {"sndcpy", "scrcpy"}

    tell application "iTerm"
        activate
        create window with default profile

        tell current session of current window
            split vertically with default profile
        end tell

        tell first session of current tab of current window
            write text "sndcpy"
        end tell
        tell second session of current tab of current window
            write text "scrcpy"
        end tell

    end tell
EOF

Run the scrsnd command and you will see a single-window opened in split view with sndcpy and scrcpy.

iterm


That’s All Folks!
Happy Coding 🖖

Buy me a cofee

Discussion

pic
Editor guide