prwiley
Posts: 11
Joined: Tue Jun 19, 2018 2:08 pm
Location: Pennsylvania USA

Can Pi respond via MQTT while OMXPlayer is playing?

Fri Aug 03, 2018 6:44 pm

I have written an iOS app that communicates with a python script running on a pi via mqtt.

The python script plays videos via an instance of OMXPlayer and automatically sends information about the video to the iOS app.

I am curious to know wether there is a way for the Python script/mqtt on the pi to respond to a mqtt message while OMXPlayer is playing on the pi. It seems that the OMXPlayer, at least in the Python script as it is at the moment, seems to block the broker from responding.

What I would like to have happen is that when the iOS app asks, the pi responds with "I am playing a video right now".

I presume the solution might have to do with threading and inter-process communication on the pi, but I just don't know enough about those topics to think about the problem.

Can someone point me in the direction of an answer? Thanks.

prwiley
Posts: 11
Joined: Tue Jun 19, 2018 2:08 pm
Location: Pennsylvania USA

Re: Can Pi respond via MQTT while OMXPlayer is playing?

Sat Aug 04, 2018 12:35 pm

Well it turns out there's no real pi/mqtt issue here.

After some careful debugging I found out that the reason why I thought I was not getting responses back from the pi via mqtt was due to the fact that my iOS app was not posting received responses on its main thread. This meant mqtt responses were so delayed that I never saw them at the right time.

Once I made sure the mqtt responses from the pi were delivered via the main thread in the iOS app (swift 4: DisapatchQue.main.asysc(){mqtt response} for those playing at home) I could see the responses immediately and was able to write code that did exactly what I wanted. The OMX player was not blocking responses as I thought it was.

Return to “Networking and servers”