-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi Player Support #2164
base: future3/develop
Are you sure you want to change the base?
Multi Player Support #2164
Changes from 109 commits
c3549eb
5aaa2d1
059566d
7992662
6b89ddf
1890016
32d53af
00d1ea5
a19382b
98cb97d
d1536de
efb3590
01ff28d
83001f7
e365417
19ebc60
271c634
92135e9
6646f9a
6e0a3f8
5c1b84d
c74ead5
cbd59de
81143cb
93fc3a9
98da122
1c505b5
f3eeb6e
1b4b540
998ed06
ade2023
2b4e666
29cc50a
d4ddadc
e1c25a7
2d8ca15
a955afb
5aef09f
6b3b6fc
9928012
cbe4749
e12a53b
5bf3b40
d0f64f4
f7d5dff
a75b0d2
df89357
6e64466
5847dad
244a0cf
04fc9fc
2bf8fbc
de9cbb7
90b54c4
665a53f
8db761f
55d721a
5412b59
ece4c2b
d47087e
fbe43a0
c094839
ecf11dc
839f1ff
c94d5db
5e3bc6d
a118f70
d0832c9
4d3c46c
731c9a9
23a0f82
bd8af97
aa8443d
9d059b4
6ec73e2
c7a3eab
20d7284
6b54f47
ef92b71
1547a42
c8bc8c0
d0e851f
fd04413
aaa935a
b910210
86e734e
36bfd79
b8fd417
9006d6f
5784f8d
3b4f448
efbe969
e85b294
7a0d170
257d177
90cc33b
d43c6fe
e3ea953
e0faa44
3d7195d
0deda1e
9a506f0
af3b281
3e0c94a
8d65be3
bb24d8a
f34815d
d24e16a
190aaf7
2eccf39
633449e
3510085
3aedd9c
8cb99d1
afcafd1
8be8ade
e5ae214
3edfa67
c8f809b
fcf2ced
d38dc0c
d880d46
ba72a18
8169592
b4ff177
83692f1
42c15f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[global] | ||
username = USER | ||
password = PASS | ||
backend = pulse | ||
device = default # Given by `aplay -L` | ||
mixer = PCM | ||
volume-control = alsa # or alsa_linear, or softvol | ||
#onevent = command_run_on_playback_event | ||
device_name = phoniebox_docker # Cannot contain spaces | ||
bitrate = 160 | ||
cache_path = cache_directory | ||
volume-normalisation = true | ||
normalisation-pregain = -10 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ services: | |
- 5555:5555 | ||
- 5556:5556 | ||
- 5557:5557 | ||
- 3001:3001 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this still belong to the Spotify PR? |
||
restart: unless-stopped | ||
tty: true | ||
volumes: | ||
|
@@ -61,3 +62,18 @@ services: | |
volumes: | ||
- ../src/webapp:/home/node/webapp | ||
- /home/node/webapp/node_modules | ||
|
||
spotifyd: | ||
build: | ||
context: ../ | ||
dockerfile: ./docker/spotifyd.Dockerfile | ||
container_name: spotifyd | ||
ports: | ||
- 1234:1234 | ||
restart: unless-stopped | ||
environment: | ||
- PULSE_SERVER=unix:/tmp/pulseaudio.socket | ||
- PULSE_COOKIE=/tmp/pulseaudio.cookie | ||
volumes: | ||
- ../shared/spotify/docker.spotifyd.conf:/etc/spotifyd.conf | ||
- $XDG_RUNTIME_DIR/pulse/native:/tmp/pulseaudio.socket |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ FROM debian:bullseye-slim | |
# Raspberry Pi environment as possible. | ||
RUN apt-get update && apt-get install -y \ | ||
libasound2-dev \ | ||
libzmq3-dev \ | ||
pulseaudio \ | ||
pulseaudio-utils \ | ||
--no-install-recommends \ | ||
|
@@ -21,16 +22,17 @@ RUN usermod -aG pulse ${USER} | |
# Install all Jukebox dependencies | ||
RUN apt-get update && apt-get install -qq -y \ | ||
--allow-downgrades --allow-remove-essential --allow-change-held-packages \ | ||
gcc at wget \ | ||
g++ at wget \ | ||
espeak mpc mpg123 git ffmpeg spi-tools netcat \ | ||
python3 python3-venv python3-dev python3-mutagen | ||
|
||
USER ${USER} | ||
WORKDIR ${HOME} | ||
|
||
ENV VIRTUAL_ENV=${INSTALLATION_PATH}/.venv | ||
RUN python3 -m venv $VIRTUAL_ENV | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
USER ${USER} | ||
WORKDIR ${HOME} | ||
COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/ | ||
|
||
RUN pip install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt | ||
|
@@ -45,7 +47,8 @@ RUN [ "$(uname -m)" = "aarch64" ] && ARCH="arm64" || ARCH="$(uname -m)"; \ | |
rm -f libzmq.tar.gz; | ||
|
||
RUN export ZMQ_PREFIX=${PREFIX} && export ZMQ_DRAFT_API=1 | ||
RUN pip install -v --no-binary pyzmq --pre pyzmq | ||
#RUN pip install -v --no-binary pyzmq --pre pyzmq | ||
RUN pip install -v --no-binary=:all: pyzmq --pre pyzmq | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the version of |
||
|
||
EXPOSE 5555 5556 | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this file, there is a lot more happening compare to here for example. Why do we need Cargo in this picture? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used another repo because I wanted to use pulseaudio: To be clear, I was using this file: which includes dbus. I need to test if the file without dbus also works: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not important, so don't focus on it for now. We we maybe be able to tweak this a little. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#An extra layer to get around this bug https://github.com/docker/buildx/issues/395 | ||
#It's there simply to download add required libraries for cargo build | ||
FROM --platform=$BUILDPLATFORM rust:bullseye AS rust_fix | ||
|
||
ENV USER=root | ||
ENV V_spotifyd=v0.3.5 | ||
|
||
WORKDIR /usr/src/spotifyd | ||
RUN apt-get -y update && \ | ||
apt-get install --no-install-recommends -y apt-transport-https ca-certificates git && \ | ||
git clone --depth 1 --branch=${V_spotifyd} https://github.com/Spotifyd/spotifyd.git . | ||
|
||
# Don't do `cargo init` or --> error: `cargo init` cannot be run on existing Cargo packages | ||
# RUN cargo init | ||
RUN mkdir -p .cargo \ | ||
&& cargo vendor > .cargo/config | ||
|
||
FROM rust:bullseye as build | ||
|
||
RUN apt-get -y update && \ | ||
apt-get install --no-install-recommends -y libasound2-dev build-essential pulseaudio libpulse-dev libdbus-1-dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need |
||
|
||
COPY --from=rust_fix /usr/src/spotifyd /usr/src/spotifyd | ||
WORKDIR /usr/src/spotifyd | ||
|
||
RUN cargo build -j 2 --release --features pulseaudio_backend,dbus_mpris --offline | ||
|
||
FROM debian:bullseye-slim as release | ||
|
||
CMD ["dbus-run-session", "/usr/bin/spotifyd", "--no-daemon"] | ||
|
||
RUN apt-get update && \ | ||
apt-get install -yqq --no-install-recommends libasound2 pulseaudio dbus libssl1.1 && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
groupadd -r spotify && \ | ||
useradd --no-log-init -r -g spotify -G audio spotify | ||
|
||
COPY --from=build /usr/src/spotifyd/target/release/spotifyd /usr/bin/ | ||
|
||
USER spotify |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Spotify Integration | ||
|
||
The Spotify integration allows to play music directly from Spotify. | ||
|
||
> [!IMPORTANT] | ||
> You need a Spotify Premium subscription to use this functionality | ||
|
||
## Needed credentials | ||
|
||
For the spotifyd daemon, you need to provide username and password of your Spotify account | ||
during installation. This is used to enable the Phoniebox to play music from Spotify. | ||
|
||
To control the playback (spotipy), you need to create an app as Spotify developer and provide the | ||
`client_id` and `client_secret` therefore follow the steps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: For Builders, we don't need to be so technical (
We could have docs in the Developers section for more advanced topics of this feature. |
||
|
||
1. Access [Developers Dashboard](https://developer.spotify.com/dashboard) | ||
2. Create an App via the button on the top right | ||
3. Fill in following fields: | ||
- App name: `your_desired_name` | ||
- Redirect URI: `http://localhost:3001` | ||
4. Save the `client_id` and `client_secret` for the installation | ||
|
||
## Post installation configuration | ||
### spotifyd | ||
|
||
The spotifyd daemon is using the username and password of your Spotify account. | ||
|
||
If the credentials have changed, you can update them in the config file located at `/etc/spotifyd.conf` | ||
|
||
### spotipy | ||
|
||
Spotipy is using `client_id` and `client_secret` to control the playback of the Phoniebox. | ||
|
||
To update the credentials, please modify the file located at `~/RPi-Jukebox-RFID/shared/settings/player.yaml` | ||
|
||
## Resources | ||
|
||
- [spotifyd](https://spotifyd.rs/) | ||
- [spotipy](https://spotipy.readthedocs.io) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,58 @@ Would you like to overwrite your configuration? [Y/n]" | |
fi | ||
} | ||
|
||
_option_spotify() { | ||
# ENABLE_SPOTIFY | ||
clear_c | ||
print_c "---------------------- SPOTIFY ---------------------- | ||
|
||
Installs an additional player, so that you can | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am adding this comment without having reviewed the actually player logic. We should not have different players. If a user does not install Spotify, we should still install the same player which only uses MPD. With this logic, we would not install "an additional player" and instead, "just Spotify". But In understand that there is more to do than just providing credentials (e.g. Developer Account)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really get what you mean. The logic is: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's just different understand of wording. Ignore my comment for now. |
||
play music from spotify. You will need to create | ||
an app in the Spotify developer dashboard to use | ||
Spotify properly | ||
|
||
Note: Spotify Premium is needed to operate player! | ||
|
||
|
||
Do you want to enable the spotify player? [y/N]" | ||
read -r response | ||
case "$response" in | ||
[yY][eE][sS]|[yY]) | ||
ENABLE_SPOTIFY=true | ||
;; | ||
*) | ||
;; | ||
esac | ||
|
||
if [ "$ENABLE_SPOTIFY" = true ]; then | ||
print_c "To configure Spotify properly, you need to create | ||
an App at https://developer.spotify.com/dashboard and provide the | ||
client_id and client_secret in the following prompts." | ||
print_c "" | ||
print_c "" | ||
print_c "Please provide the Spotify username" | ||
read -r response_username | ||
SPOT_USERNAME="${response_username}" | ||
|
||
print_c "Please provide the Spotify password" | ||
read -r response_password | ||
SPOT_PASSWORD="${response_password}" | ||
|
||
print_c "Please provide the client_id of the Spotify App" | ||
read -r response_client_id | ||
SPOT_CLIENT_ID="${response_client_id}" | ||
|
||
print_c "Please provide the client_secret of the Spotify App" | ||
read -r response_client_secret | ||
SPOT_CLIENT_SECRET="${response_client_secret}" | ||
fi | ||
|
||
log "ENABLE_SPOTIFY=${ENABLE_SPOTIFY}" | ||
if [ "$ENABLE_SPOTIFY" = true ]; then | ||
log "Spotify service will be enabled with username ${SPOT_USERNAME} and client_id ${SPOT_CLIENT_ID}" | ||
fi | ||
} | ||
|
||
_option_rfid_reader() { | ||
# ENABLE_RFID_READER | ||
clear_c | ||
|
@@ -328,6 +380,7 @@ _run_customize_options() { | |
_option_bluetooth | ||
_option_disable_onboard_audio | ||
_option_mpd | ||
_option_spotify | ||
_option_rfid_reader | ||
_option_samba | ||
_option_webapp | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't commit this :-) It'll be vey verbose and irrelevant