MediaThread Class

Inheritance diagram of MediaThread

class MediaThread(target=None)

A thread that cleanly exits on interpreter shutdown, and provides a sleep method that can be interrupted and a termination method.

Variables:
  • condition – Lock condition on all instance variables.
  • stopped – True if stop has been called.

Constructor:

__init__(target=None)

Methods:

notify() Interrupt the current sleep operation.
run()
sleep(timeout) Wait for some amount of time, or until notified.
start()
stop() Stop the thread and wait for it to terminate.

Methods

MediaThread.notify()

Interrupt the current sleep operation.

If the thread is currently sleeping, it will be woken immediately, instead of waiting the full duration of the timeout.

MediaThread.run()
MediaThread.sleep(timeout)

Wait for some amount of time, or until notified.

Parameters:timeout (float) – Time to wait, in seconds.
MediaThread.start()
MediaThread.stop()

Stop the thread and wait for it to terminate.

The stop instance variable is set to True and the condition is notified. It is the responsibility of the run method to check the value of stop after each sleep or wait and to return if set.

Table Of Contents

Previous topic

MediaEvent Class

Next topic

Player Class