Skip to content

Commit

Permalink
Upgrade Android project far enough that it'll build and be publishabl…
Browse files Browse the repository at this point in the history
…e on Google Play.
  • Loading branch information
kescherCode committed Mar 20, 2024
1 parent 7a5c843 commit f7da593
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 37 deletions.
54 changes: 37 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
PulseDroid - Network raw audio player
PulseDroid - simple TCP protocol player.
-------------------------------------

PulseDroid is an audio player for Android that plays 48000Hz pcm16le stereo
audio from a simple TCP connection.
PulseDroid is an audio player for Android that plays pcm16le mono/stereo
audio from a simple TCP connection, as provided by PulseAudio/PipeWire,
but also by a few other implementations.

PulseAudio has `module-simple-protocol-tcp` that provides such an endpoint, which
allows streaming audio to an Android device.
PulseAudio/PipeWire has `module-simple-protocol-tcp` that provides such an endpoint, which
allows streaming audio to, among others, this app.

## Setup

1. Load `module-simple-protocol-tcp`.

Warning: this PulseAudio module provides an endpoint that allows anyone in
your network to listen to the connected source, and to play back audio.
Make sure that your network is trusted or that you secure the connection
appropriately.
Warning: this PulseAudio module provides an endpoint that allows anyone in
your network to listen to the connected source, and to play back audio.
Make sure that your network is trusted or that you secure the connection
appropriately, e.g. using a TLS tunnel or WireGuard.

Run the following to add and configure the module; of course, the port and source can be modified as you want:
Run the following to add and configure the module; of course, the port and source can be
modified as you want, and rate can be either 44100 or 48000, and channels can be either 1 (mono)
or 2 (stereo),
depending on what you'll set in the app:

pactl load-module module-simple-protocol-tcp rate=44100 format=s16le channels=1 source=0 record=true port=12345 listen=0.0.0.0

In case you want to unload, simply run:

pactl unload-module module-simple-protocol-tcp

or, if you have multiple TCP sinks and want to unload a specific one, unload the number returned
in the the first command for it (the number is an example):

pactl unload-module 536870918

2. Install the app and start it.

3. Enter the host and port of your PulseAudio endpoint and hit play.
Expand All @@ -34,23 +47,30 @@ TODO: more advanced setup possible

The original project is
[https://github.com/dront78/PulseDroid](https://github.com/dront78/PulseDroid),
but it has been immediately abandoned after the first commit, leaving it in
very bare-bones state.
but it was immediately abandoned after the first commit, leaving it in a very bare-bones state.

[https://github.com/Konubinix/PulseDroid](https://github.com/Konubinix/PulseDroid)
shortely picked up the project about 5 years later, improving the android
briefly picked up the project about 5 years later, improving the android
experience, for example by using a foreground service.

In 2018 I, ferreum, was looking for just such an app, found this project and
In 2018, ferreum, was looking for just such an app, found this project and
reworked everything, wanting a more polished experience. The app can now play
audio in the background after closing the main screen, has improved buffering,
error handling, state handling, and a modernized structure. More improvements
to follow as I see fit.
error handling, state handling, and a modernized structure.

In 2022, [kescher](https://github.com/kescherCode/PulseDroid) added a few options for sample rate
and channel count adjustments,
as well as ways to automatically start the foreground service with the set host and port,
as well an option to restart the stream whenever there's an error.

In 2024, this app
got [published into the Play Store](https://play.google.com/store/apps/details?id=at.kescher.pulsedroid).

And now a message from the original creator at the beginning of this project:

> This software is a some kind of network music player I done for my personal purposes.
> I use it with PulseAudio over network to watch a video or listen music from my pc with in a headphones ;)
> I use it with PulseAudio over network to watch a video or listen music from my pc with in a
> headphones ;)
>
> It is very simple to setup a PulseAudio server to send audio output over network
>
Expand Down
24 changes: 11 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 32
buildToolsVersion '30.0.3'
compileSdkVersion 34

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

defaultConfig {
multiDexEnabled true
applicationId 'at.kescher.pulsedroid'
minSdkVersion 14
targetSdkVersion 32
targetSdkVersion 34

// version code: each number in the version string gets two digits (leading zero removed for first one). one additional digit for pre-release versions.
// So: 2.0.0 is: 02 + 00 + 00 + 0
versionCode 200030
versionName "2.0.3"
versionName "2.1.0"
}

buildTypes {
Expand All @@ -29,20 +28,19 @@ android {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'

signingConfig null
}
}
namespace 'at.kescher.pulsedroid'
}

dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.11.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="at.kescher.pulsedroid">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<application
android:allowBackup="true"
Expand All @@ -30,6 +30,7 @@
</activity>
<service
android:name="at.kescher.pulsedroid.PulsePlaybackService"
android:label="@string/playback_service_label" />
android:label="@string/playback_service_label"
android:foregroundServiceType="mediaPlayback" />
</application>
</manifest>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.android.tools.build:gradle:8.3.1'
}
}

Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
org.gradle.configuration-cache=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip

0 comments on commit f7da593

Please sign in to comment.