Base classes

Provides common base classes and tools.

class cpl_media.common.KivyMediaBase(**kwargs)

Bases: Configurable

A base classes for all the players and recorders.

It provides methods for the kivy and internal threads to interact safely. Specifically, for the internal threads to schedule code to be executed in the kivy thread.

call_in_kivy_thread(f, *args, **kwargs)

Schedules Kivy to call the function in the Kivy thread.

Parameters
  • f – The function to call.

  • args – The positional args to pass to the function.

  • kwargs – The keyword args to pass to the function.

exception(e)

Called from under an exception, to report the exception to cpl_media.error_callback().

Parameters

e – The exception instance.

increment_in_kivy_thread(prop, value=1)

Schedules kivy to increment the property by the specified value in the kivy thread.

Parameters
  • prop – The instance property name to increment.

  • value – The value by which it will be incremented.

kivy_thread_queue = None

The queue that the kivy thread will read from and process messages.

process_queue_in_kivy_thread(*largs)

Method that is called in the kivy thread when trigger_run_in_kivy is triggered. It reads messages from the thread.

setattr_in_kivy_thread(prop, value)

Schedules kivy to set the property to the specified value in the kivy thread.

Parameters
  • prop – The instance property name to set.

  • value – The value the property will be set to.

setattrs_in_kivy_thread(**kwargs)

Schedules kivy to set the properties to the specified values in the kivy thread.

Parameters

kwargs – The dict of values.

stop_all(join=False)

Causes all internal threads to stop and exit.

Parameters

join – Whether to wait and block the calling thread until the internal threads exit.

trigger_run_in_kivy = None

A Kivy clock trigger that will cause process_queue_in_kivy_thread() to be called on the next frame in the kivy thread.