Browse Source

hot mess, added favicons, tweaks to code, config.sh has become an unorganized notepad. Will fix up for the blog post

master
Sean Clarke 2 months ago
parent
commit
1f9acb8614
  1. 40
      index.html
  2. BIN
      php/android-chrome-192x192.png
  3. BIN
      php/android-chrome-512x512.png
  4. BIN
      php/apple-touch-icon.png
  5. 32
      php/config.sh
  6. BIN
      php/favicon-16x16.png
  7. BIN
      php/favicon-32x32.png
  8. BIN
      php/favicon.ico
  9. 62
      php/index.html
  10. 6
      php/main.css
  11. 14
      php/radio.php
  12. 1
      php/site.webmanifest

40
index.html

@ -1,40 +0,0 @@
<html>
<head>
<title>Doggie Radio UI - By Seanland</title>
<link rel="stylesheet" href="main.css">
<script type="text/javascript" src="jquery-3.4.1.min.js"></script>
</head>
<h1>Doggie Radio</h1>
<a href='#' onclick="radio(1);">Seanland's Game Music</a>
<a href='#' onclick="radio(2);">Seanland's Top 100s</a>
<a href='#' onclick="radio(3);">Seanland's Collection</a>
<a href='#' onclick="radio(stop);" class="stop">Stop Music</a>
<script type='text/javascript'>
//AJAX function
function radio(com) {
// change IP based on the player's address
var ip = "192.168.1.40";
$.ajax({
type: "POST",
url: "https://" + ip + "/radio.php",
xhrFields: {
withCredentials: true
},
data: "radio=" + com,
success: function(msg){
// may add in the future
},
error: function (xhr, status) {
// handle errors
}
});
}
</script>
</html>

BIN
php/android-chrome-192x192.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
php/android-chrome-512x512.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

BIN
php/apple-touch-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

32
setup/config.sh → php/config.sh

@ -1,5 +1,26 @@
##### NOT IN EXECUTABLE STATE! #####
## SPECIFIC TO ORANGEPI
cd /usr/local/sbin/
bash resize_rootfs.sh
## Configure WiFi on the headless server
# setup wireless on the orange pi (or whatever wireless/headless device being used)
sudo wpa_passphrase NETWORK_NAME NETWORK_PASSWORD > /etc/network/wpa_supplicant.conf
# Add the below contents to the interface file wlan0 most likely.
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
pre-up sudo wpa_supplicant -B -iwlan0 -c/etc/network/wpa_supplicant.conf -Dwext
post-down sudo killall -q wpa_supplicant
## Reboot and disconnect wired :)
## Then, disable wired (or unplug) and reboot again
# To install php and apache
echo "y" | sudo apt-get install php
@ -7,6 +28,11 @@ echo "y" | sudo apt-get install php
sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
# modify the ssl configuration file to add the location of the keys
### Modify certificate in default-ssl.conf
## Also SSLVerifyClient none
#enabling ssl and restarting the services
sudo apachectl configtest
sudo a2enmod ssl
@ -24,3 +50,9 @@ echo "y" | sudo apt-get install mpd
mpc add http://192.168.1.215:8000/game-music.ogg
mpc add http://192.168.1.215:8000/top-100.ogg
mpc add http://192.168.1.215:8000/seanland.ogg
# Fix volume level to 100% if too quiet.
sudo amixer set 'Line Out' 100%
# FOr favicon
# https://favicon.io/favicon-converter/

BIN
php/favicon-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 962 B

BIN
php/favicon-32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
php/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

62
php/index.html

@ -0,0 +1,62 @@
<html>
<head>
<title>Doggie Radio UI - By Seanland</title>
<link rel="stylesheet" href="main.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<!-- <script type="text/javascript" src="jquery-3.4.1.min.js"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<h1>Doggie Radio</h1>
<p>Now Playing:</p>
<p id="now-playing"></p>
<a href='#' onclick="radio(1);">Play</a>
<!-- <a href='#' onclick="radio(2);">Seanland's Top 100s</a>
<a href='#' onclick="radio(3);">Seanland's Collection</a> -->
<a href='#' onclick="radio(stop);" class="stop">Stop Music</a>
<script type='text/javascript'>
updateMusic();
function updateMusic(){
getSong();
setInterval(function(){
getSong();
}, 5000);
}
function getSong(){
$.getJSON("https://radio.snld.ca/status-json.xsl", function(song){
$("#now-playing").text(song.icestats.source.title + " by " + song.icestats.source.artist);
});
}
//AJAX function
function radio(com) {
// change IP based on the player's address
var ip = "192.168.10.71";
$.ajax({
type: "POST",
url: "https://" + ip + "/radio.php",
xhrFields: {
withCredentials: true
},
data: "radio=" + com,
success: function(msg){
// may add in the future
},
error: function (xhr, status) {
// handle errors
}
});
}
</script>
</html>

6
main.css → php/main.css

@ -1,4 +1,4 @@
h1 {
h1, p {
font-size: 7vw;
color: blue;
text-align: center;
@ -19,3 +19,7 @@ a {
a.stop {
background: red;
}
body {
position: -50%;
}

14
radio.php → php/radio.php

@ -1,5 +1,7 @@
<?php
if (isset($_POST['radio'])) {
header("Access-Control-Allow-Origin: http://192.168.10.71");
header("Access-Control-Allow-Credentials: true");
radioControl($_POST['radio']);
}
@ -8,12 +10,12 @@
case '1':
shell_exec('mpc play 1');
break;
case '2':
shell_exec('mpc play 2');
break;
case '3':
shell_exec('mpc play 3');
break;
// case '2':
// shell_exec('mpc play 2');
// break;
// case '3':
// shell_exec('mpc play 3');
// break;
default:
shell_exec('mpc stop');
break;

1
php/site.webmanifest

@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
Loading…
Cancel
Save