Hi Terry,

> > > I want to run the MP3 Player inside the same program if possible.
>
> To make it easier to get the interaction between the bells and the
> music.  For example, when we run the wedding sequence, we will first
> ring changes in the tower, then play the Wedding March followed by
> Widor's Toccata and Fugue in the chancel, then changes in the tower.
>
> I'm sure it can be done with two separate programs, and maybe it would
> be better that way, but the two programs would need to communicate.
> Also, we will want to do a sequence of change rings in the tower on
> other occasions that still work even the chimes are still running.

OK, I don't get the detail, but here's the current on-the-quarter code.

    while quarter_rings > 0:
        os.system('mpg321 -g 100 -q ./mp3/Two_Chimes.mp3')
        time.sleep(interval)
        quarter_rings -= 1

    time.sleep(march_delay)
    os.system('mpg321 -g 20 -q ./mp3/Wedding_March.mp3')
    time.sleep(changes_delay)
    os.system('mpg321 -g 100 -q ./mp3/amersham.mp3')

os.system() is forking a new process, that creates a copy of your Python
program, has that child exec mpg321 thus overlaying /usr/bin/python with
/usr/bin/mpg321, and all the while the parent that did the fork waits
for the child to exit.

I think you're saying you want to kick off one tune and then, whilst
that's still playing, kick off another a little later?  Append ` &' to
your mpg321 invocation so the /bin/sh running your os.system string puts
the program in the background and exits, allowing os.system to return.

More complicated needs can probably be satisfied with
https://docs.python.org/2/library/subprocess.html instead of os.system.

Cheers, Ralph.

-- 
Next meeting:  Bournemouth, Tuesday, 2017-02-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:[email protected] / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue     / TO THE LIST OR THE AUTHOR

Reply via email to