Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-brooks committed Apr 22, 2019
1 parent 3abff88 commit b08f4af
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,49 @@ This script allows streaming audio between two Linux machines, for example, a la
* netcat (any)

## Instructions
Install sever dependencies, for example, if you're using a Raspberry Pi, SSH into it and run:
### Server
#### Get the script
SSH into your server, and download the scripts via git:

`git clone https://github.com/connor-brooks/play_stdin.sh.git`

#### Install dependancies
If you're using a Raspberry Pi:

`sudo apt-get install ffplay nmap`

Then start the server, by running:
### Configure (optional)
With the text editor of you choice, edit line 2 of `play_stdin_server.sh` and change the `CONTROLLER_PORT` variable to whatever port you want, for example run:

`nano play_stdin_server.sh`

Change the port number, and save.

#### Run the server
To start the server, run the following command:
`./play_stdin_server.sh &`

You can now disconnect from the server.
You can now disconnect from the Raspberry Pi, but before you do, make sure to take note of your servers IP address, buy running the following:

`sudo ifconfig`

On your client, you can now run:
Generally your ip address will be in the format of `192.168.xxx.xxx`


### Client
#### Get the script
`git clone https://github.com/connor-brooks/play_stdin.sh.git`

#### Configure:
Using the text editor of your choice, edit line 2 and 3 of `play_stdin.sh` to match the port and IP of your server.

#### Play some music
`cat music.mp3 | ./play_stdin.sh &`

Where `music.mp3` is the song you'd like to play.

#### Play and pause

To pause from your client:

`./play_stdin.sh TOGGLE`
Expand Down
1 change: 0 additions & 1 deletion play_stdin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ echo "Playing, you can kill this process now!"
# pipe arg0 (The cat'd audio file) to the audio stream server
(netcat $CONTROLLER_IP $PLAYER_PORT <&0)
exit

27 changes: 11 additions & 16 deletions play_stdin_server.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
#!/bin/bash

CONTROLLER_PORT=1337
AUDIO_SERVER_PLAYER="ffplay -nodisp -i -"
CONTROLLER_PIPE_NAME=play_stdin_server
CONTROLLER_PIPE_FILE=/tmp/$CONTROLLER_PIPE_NAME
CONTROLLER_PORT=1337

AUDIO_SERVER_IS_RUNNING=0
AUDIO_SERVER_IS_PAUSED=0
AUDIO_SERVER_PID=0

AUDIO_SERVER_PLAYER="ffplay -nodisp -i -"


# Create the pipe
setup_server_fifo () {
mkfifo $1
return
}

################
# Server commands
#################
###################
# Server commands #
###################
# EXIT, kill the whole server
server_exit (){
echo "GOODBYE!" > $CONTROLLER_PIPE_FILE;
Expand Down Expand Up @@ -79,6 +69,12 @@ command_respond () {
esac
}

# Create the pipe
setup_server_fifo () {
mkfifo $1
return
}

# Create the pipe for commands
setup_server_fifo $CONTROLLER_PIPE_FILE

Expand All @@ -94,4 +90,3 @@ while read line
do
command_respond $line
done

0 comments on commit b08f4af

Please sign in to comment.