# importing vlc module from email import message from pydoc import cli from statistics import median import vlc from time import sleep import paho.mqtt.client as mqtt from video import Video import multiprocessing class App: def __init__(self, client): self.client = client self.video = Video(4000, 1000) def on_connect(self, client, userdata, flags, rc): print("Connected with result code "+str(rc)) self.client.subscribe("video") def on_message(self, client, userdata, msg): print(msg.topic+" "+str(msg.payload)) if msg.payload == b'start': print("Start") self.video.setVideo("slave/sample-mp4-file.mp4") self.x = multiprocessing.Process(target = self.video.start) self.x.start() elif msg.payload == b'stop': print("Stop") self.x.terminate() client = mqtt.Client() app = App(client) client.on_connect = app.on_connect client.on_message = app.on_message client.connect("10.173.54.35", 1883, 60) client.loop_forever()