# importing vlc module from time import sleep import paho.mqtt.client as mqtt from video import Video import multiprocessing import sys class App: def __init__(self, client, x, y): self.client = client self.video = Video(x, y) 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.x = multiprocessing.Process(target = self.video.start, args=("slave/sample-mp4-file.mp4",)) self.x.start() elif msg.payload == b'stop': print("Stop") self.x.terminate() def main(): client = mqtt.Client() app = App(client, int(sys.argv[1]), int(sys.argv[2])) client.on_connect = app.on_connect client.on_message = app.on_message client.connect("10.173.54.35", 1883, 60) client.loop_forever() if __name__ == "__main__": main()