Skip to content

Commit

Permalink
Bluetooth source support (#14)
Browse files Browse the repository at this point in the history
Support using Linamp as a Bluetooth audio receiver
  • Loading branch information
Rodmg authored Dec 18, 2024
1 parent 06d3571 commit efd5edb
Show file tree
Hide file tree
Showing 18 changed files with 1,054 additions and 305 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Music player app for Linamp - Your favorite music player of the 90s, but in real
- python3-pip
- python3-full
- python3-dev
- python3-dbus-next
- libdiscid0

## Development
Expand All @@ -34,7 +35,7 @@ sudo apt-get install build-essential qt6-base-dev qt6-base-dev-tools qt6-multime
sudo apt-get install libtag1-dev libasound2-dev libpulse-dev libpipewire-0.3-dev libdbus-1-dev -y

# Install dependencies for Python (for CD player functionality)
sudo apt-get install vlc libiso9660-dev libcdio-dev libcdio-utils swig python3-pip python3-full python3-dev libdiscid0 libdiscid-dev -y
sudo apt-get install vlc libiso9660-dev libcdio-dev libcdio-utils swig python3-pip python3-full python3-dev python3-dbus-next libdiscid0 libdiscid-dev -y

# Create Python venv and install Python dependencies (for CD player functionality)
## IMPORTANT: Make sure you are on the folder where you cloned this repo before running the following commands:
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
linamp (1.3.0) bookworm; urgency=medium

* Feature: Bluetooth Source, use Linamp as a Bluetooth audio receiver

-- Rodrigo Méndez <[email protected]> Tue, 17 Dec 2024 22:37:00 -0600

linamp (1.2.1) bookworm; urgency=medium

* Bugfix: Fixed glitches on spectrum analyzer for views that use audiospectrumcatpure class (CD player, Bluetooth player)
Expand Down
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Depends:
python3-libdiscid,
python3-musicbrainzngs,
python3-cdio,
python3-vlc
python3-vlc,
python3-dbus-next
Description: Your favorite music player of the 90s, but in real life
Music player app for Linamp - Your favorite music player of the 90s,
but in real life.
Expand Down
2 changes: 2 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ override_dh_auto_install:
mkdir -p debian/linamp/usr/lib/python3/dist-packages/linamp
cp python/linamp/__init__.py debian/linamp/usr/lib/python3/dist-packages/linamp/__init__.py
cp python/linamp/cdplayer.py debian/linamp/usr/lib/python3/dist-packages/linamp/cdplayer.py
cp -r python/linamp/baseplayer debian/linamp/usr/lib/python3/dist-packages/linamp/baseplayer
cp -r python/linamp/btplayer debian/linamp/usr/lib/python3/dist-packages/linamp/btplayer

mkdir -p debian/linamp/usr/share/applications/
cp linamp.desktop debian/linamp/usr/share/applications/
Expand Down
3 changes: 2 additions & 1 deletion python/linamp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .cdplayer import *
from linamp.cdplayer import *
from linamp.btplayer import *
1 change: 1 addition & 0 deletions python/linamp/baseplayer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from linamp.baseplayer.baseplayer import *
85 changes: 85 additions & 0 deletions python/linamp/baseplayer/baseplayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from enum import Enum

class PlayerStatus(Enum):
Idle = 'idle'
Playing = 'playing'
Stopped = 'stopped'
Paused = 'paused'
Error = 'error'
Loading = 'loading'


# Base Player abstract class
class BasePlayer:
# Called when the source is selected in the UI or whenever the full track info needs to be refreshed
def load(self) -> None:
pass

# Called when the source is deselected in the UI
def unload(self) -> None:
pass

# Basic playback control funcions called on button press
def play(self) -> None:
pass

def stop(self) -> None:
pass

def pause(self) -> None:
pass

def next(self) -> None:
pass

def prev(self) -> None:
pass

# Go to a specific time in a track while playing
def seek(self, ms: int) -> None:
pass

# Playback mode toggles
def set_shuffle(self, enabled: bool) -> None:
pass

def set_repeat(self, enabled: bool) -> None:
pass

# Eject button
def eject(self) -> None:
pass

# -------- Status Functions --------

# Called constantly during playback to update the time progress
def get_postition(self) -> int:
return 0

def get_shuffle(self) -> bool:
return False

def get_repeat(self) -> bool:
return False

# Returns the str representation of PlayerStatus enum
def get_status(self) -> str:
status = PlayerStatus.Idle
return status.value

# tuple with format (tracknumber: int, artist, album, title, duration_ms: int, codec: str, bitrate_bps: int, samplerate_hz: int)
def get_track_info(self) -> tuple[int, str, str, str, int, str, int, int]:
return (1, '', '', '', 1, 'AAC', 256000, 44100)

# Return any message you want to show to the user. tuple with format: (show_message: bool, message: str, message_timeout_ms: int)
def get_message(self) -> tuple[bool, str, int]:
return (False, '', 0)

# Called whenever the UI wants to force clear the message
def clear_message(self) -> None:
pass

# -------- Polling functions to be called by a timer --------

def poll_events(self) -> bool:
return False
1 change: 1 addition & 0 deletions python/linamp/btplayer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from linamp.btplayer.btplayer import *
Loading

0 comments on commit efd5edb

Please sign in to comment.