Entrance themes: Difference between revisions

From NURDspace
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:
|Status=Finished
|Status=Finished
|Purpose=Fun
|Purpose=Fun
|Location=SlabPi
|Picture=WWEEntrance.jpg
|Picture=WWEEntrance.jpg
|Tool=No
|Location=ask melan
}}
}}
==What==
==What==


We have a script running on [[SlabPi]] that plays entrance theme audio when a member enters the space.
We have a script running on [[spacesound]] that plays entrance theme audio when a member enters the space.
 
It checks if a member is entering on [[MQTT]], it pauses MPD, plays a song from the folder "themes" that was mounted from [[Egg]] with mpg123 and resumes MPD.


It checks if a member is entering on [[MQTT]] ,it pauses MPC, plays a song from the folder "themes" that was mounted from [[Egg]] with mpg123 and resumes MPC.
It needs paho installed. More info about installing paho here: [[Shutdown Script]]
It needs paho installed. More info about installing paho here: [[Shutdown Script]]




==The script==
The script is on https://gist.github.com/buzztiaan/141ab1dc469b8f7db1d362b273b73746
 
<pre><nowiki>
#!/usr/bin/env python
#Invict & Niz 2019
import time
import paho.mqtt.client as paho
import json
import os
from mpd import MPDClient
broker="arbiter.vm.nurd.space"
#define callback
def on_message(client, userdata, message):
    parsed_json = json.loads(message.payload.decode("utf-8"))
    print("received message =",str(message.payload.decode("utf-8")))
    print(parsed_json['name'])
    mclient = MPDClient()              # create client object
    mclient.timeout = 10                # network timeout in seconds (floats allowed), default: None
    mclient.idletimeout = None          # timeout for fetching the result of the idle command is handled seperately, default: None
    mclient.connect("slabpi.dhcp.nurd.space", 6600)  # connect to localhost:6600
    print(mclient.mpd_version)          # print the MPD version
    mclient.pause(1)
    os.system('mpg123 /mnt/mp3/themes/' + parsed_json["name"] + '.mp3')
    mclient.pause(0)
    mclient.disconnect()
 
client= paho.Client("themesong")
######Bind function to callback
client.on_message=on_message
#####
print("connecting to broker ",broker)
client.connect(broker)#connect
print("subscribing ")
client.subscribe("space/door/front")#subscribe
client.loop_forever()
</nowiki></pre>

Latest revision as of 21:51, 9 May 2022

Entrance themes
WWEEntrance.jpg
Participants Dennis
Skills Programming
Status Finished
Niche
Purpose Fun
Tool No
Location ask melan
Cost
Tool category

Entrance themes

WWEEntrance.jpg {{#if:No | [[Tool Owner::{{{ProjectParticipants}}} | }} {{#if:No | [[Tool Cost::{{{Cost}}} | }}


What

We have a script running on spacesound that plays entrance theme audio when a member enters the space.

It checks if a member is entering on MQTT, it pauses MPD, plays a song from the folder "themes" that was mounted from Egg with mpg123 and resumes MPD.

It needs paho installed. More info about installing paho here: Shutdown Script


The script is on https://gist.github.com/buzztiaan/141ab1dc469b8f7db1d362b273b73746