Skip to content

Control your phone/emulator's media playback from your notification panel through MPRIS.

Notifications You must be signed in to change notification settings

AzlanCoding/scrcpyMediaController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrcpyMediaController

Screenshot of scrcpyMediaController in swaync Control your phone/emulator's media playback from your notification panel through MPRIS.
This script works independently from scrcpy and does not require it to be installed or running for use.
Take note that this "simple" script only works on GNU/Linux with MPRIS and only controls media playback. It does not forward audio. Use scrcpy or sndcpy to do that.
Credits: Default album art icon (icon.png) from scrcpy repository.
Tested on Ubnutu Mantic 23.10 running Hyprland with swaync.

Setup

Clone this repo, install Python3.12 and create a virtual environment

git clone https://github.com/AzlanCoding/scrcpyMediaController
sudo apt install python3.12 python3.12-venv python3.12-dev libgirepository1.0-dev libcairo2-dev
cd scrcpyMediaController
python3.12 -m venv virtualEnv
source ./virtualEnv/bin/activate
pip install mpris_server
exit

Once done can remove build packages:

sudo apt remove python3.12-dev libgirepository1.0-dev libcairo2-dev
sudo apt autoremove

Running

Connect your device to your laptop via adb and run the command below.

./start_scrcpyMediaController.sh

Alternatively, you can manually activate the environment and run main.py using the following commands:

cd scrcpyMediaPlayer
source ./virtualEnv/bin/activate
python main.py

Running in background

Setting up

nohup ./start_scrcpyMediaController.sh 0 &

DO NOT RUN ./start_scrcpyMediaController.sh & disown. Process will hang when print() or any standard output is called in the program.

Killing

use Btop++ or something to send signal 15 (SIGTERM) and terminate the process with the program named python. Don't use SIGKILL!!!

Customizing

In main.py you can change the 3 variables in lines 10-12

artUrl = "file://"+os.path.join(os.path.dirname(__file__), 'icon.png')
playerName = "scrcpy"
updateFreq = 1

artUrl holds the location of the album art icon (player icon).
playerName defines the name of the player.
updateFreq specifies how frequent the player checks for updates in seconds.

To Do

  • Convert the variables above to flags you can pass
  • Windows support using winrt.windows.media.control.GlobalSystemMediaTransportControlsSessionManager as suggested by Bing Chat
  • First Release

About

Control your phone/emulator's media playback from your notification panel through MPRIS.

Resources

Stars

Watchers

Forks

Releases

No releases published