popcornmix / omxplayer

omxplayer
GNU General Public License v2.0
1.01k stars 334 forks source link

Simplest Model for Playing, Playing New #808

Closed AlexMaghen closed 2 years ago

AlexMaghen commented 2 years ago

Hi. Thank you for omxplayer. It's great. I would like to be using it to play audio segments and interrupt them with other audio segments based on a user's interactions, etc. I'm having some bugginess which I don't really understand but first I want to make sure that I am doing this properly.

I am instantiating the object and playing the audio as follows: p = OMXPlayer(aud, args=['-o', 'alsa:hw:1,0']) p.exitEvent += lambda _, exit_code: playerExit(exit_code)

That seems to work. Where I'm getting into trouble is when I want to interrupt that audio and play a different one instead. To do this, I first have to determine if "p" (above) is an OMXPlayer, in case this is the first time p is being used. I think I should be using isinstace() for that, but I admit I don't know what parameter 2 of isinstrace(p, ???) should be (tried a few things and none of it works).

Second, if p is of type OMXPlayer, should I use p.load() to start a new audio? What's the best way to make sure I'm always cutting off another audio if it was playing, without knowing for sure what was already happening?

Many thanks and sorry for my poor python!

Alex

popcornmix commented 2 years ago

omxplayer is a c code application. If you are having issues with using a python wrapper for it, then best ask there. Possibly this one? https://github.com/willprice/python-omxplayer-wrapper

AlexMaghen commented 2 years ago

Oops! Sorry about that!