Clapper.Reactable

g Clapper.Reactable Clapper.Reactable GObject.GInterface GObject.GInterface GObject.GInterface->Clapper.Reactable

Implementations:

None

Methods

get_player ()

queue_append_sync (item)

queue_clear_sync ()

queue_insert_sync (item, after_item)

queue_remove_sync (item)

timeline_insert_sync (timeline, marker)

timeline_remove_sync (timeline, marker)

Virtual Methods

do_item_updated (item, flags)

do_message_received (msg)

do_mute_changed (mute)

do_played_item_changed (item)

do_position_changed (position)

do_queue_cleared ()

do_queue_item_added (item, index)

do_queue_item_removed (item, index)

do_queue_item_repositioned (before, after)

do_queue_progression_changed (mode)

do_speed_changed (speed)

do_state_changed (state)

do_volume_changed (volume)

Properties

None

Signals

None

Fields

None

Class Details

class Clapper.Reactable
Bases:

GObject.GInterface

Structure:

Clapper.ReactableInterface

An interface for creating enhancers that react to the playback and/or events that should influence it.

New in version 0.10.

get_player()
Returns:

A reference to the parent Clapper.Player.

Return type:

Clapper.Player or None

Get the [class`Clapper`.Player] that this reactable is reacting to.

This is meant to be used in implementations where reaction goes the other way around (from enhancer plugin to the player). For example some external event needs to influence parent player object like changing its state, seeking, etc.

Note that enhancers are working in a non-main application thread, thus if you need to do operations on a [class`Clapper`.Queue] such as adding/removing items, you need to switch thread first. Otherwise this will not be thread safe for applications that use single threaded toolkits such as #GTK. You can do this manually or use provided reactable convenience functions.

Due to the threaded nature, you should also avoid comparisons to the current properties values in the player or its queue. While these are thread safe, there is no guarantee that values/objects between threads are still the same in both (or still exist). For example, instead of using [property`Clapper`.Queue:current_item], monitor it with implemented [vfunc`Clapper`.Reactable.played_item_changed] instead, as these functions are all serialized into your implementation thread.

New in version 0.10.

queue_append_sync(item)
Parameters:

item (Clapper.MediaItem) – a Clapper.MediaItem

A convenience function that within application main thread synchronously appends an item to the playback queue of the player that self belongs to.

Reactable enhancers should only modify the queue from the application main thread, switching thread either themselves or using this convenience function that does so.

Note that this function will do no operation if called when there is no player set yet (e.g. inside enhancer construction) or if enhancer outlived the parent instance somehow. Both cases are considered to be implementation bug.

New in version 0.10.

queue_clear_sync()

A convenience function that within application main thread synchronously clears the playback queue of the player that self belongs to.

Reactable enhancers should only modify the queue from the application main thread, switching thread either themselves or using this convenience function that does so.

Note that this function will do no operation if called when there is no player set yet (e.g. inside enhancer construction) or if enhancer outlived the parent instance somehow. Both cases are considered to be implementation bug.

New in version 0.10.

queue_insert_sync(item, after_item)
Parameters:

A convenience function that within application main thread synchronously inserts an item to the playback queue position after after_item of the player that self belongs to.

This function uses after_item instead of position index in order to ensure desired position does not change during thread switching.

Reactable enhancers should only modify the queue from the application main thread, switching thread either themselves or using this convenience function that does so.

Note that this function will do no operation if called when there is no player set yet (e.g. inside enhancer construction) or if enhancer outlived the parent instance somehow. Both cases are considered to be implementation bug.

New in version 0.10.

queue_remove_sync(item)
Parameters:

item (Clapper.MediaItem) – a Clapper.MediaItem

A convenience function that within application main thread synchronously removes an item from the playback queue of the player that self belongs to.

Reactable enhancers should only modify the queue from the application main thread, switching thread either themselves or using this convenience function that does so.

Note that this function will do no operation if called when there is no player set yet (e.g. inside enhancer construction) or if enhancer outlived the parent instance somehow. Both cases are considered to be implementation bug.

New in version 0.10.

timeline_insert_sync(timeline, marker)
Parameters:

A convenience function that within application main thread synchronously inserts marker into timeline.

Reactable enhancers should only modify timeline of an item that is already in queue from the application main thread, switching thread either themselves or using this convenience function that does so.

New in version 0.10.

timeline_remove_sync(timeline, marker)
Parameters:

A convenience function that within application main thread synchronously removes marker from timeline.

Reactable enhancers should only modify timeline of an item that is already in queue from the application main thread, switching thread either themselves or using this convenience function that does so.

New in version 0.10.

do_item_updated(item, flags) virtual
Parameters:

An item in queue got updated.

This might be (or not) currently played item. Implementations can compare it against the last item from [vfunc`Clapper`.Reactable.played_item_changed] if they need to know that.

New in version 0.10.

do_message_received(msg) virtual
Parameters:

msg (Gst.Message) – a Gst.Message

Custom message from user was received on reactables bus.

New in version 0.10.

do_mute_changed(mute) virtual
Parameters:

mute (bool) – True if player is muted, False otherwise

Player mute state changed.

New in version 0.10.

do_played_item_changed(item) virtual
Parameters:

item (Clapper.MediaItem) – a Clapper.MediaItem that is now playing

New media item started playing. All following events (such as position changes) will be related to this item from now on.

New in version 0.10.

do_position_changed(position) virtual
Parameters:

position (float) – a decimal number with current position in seconds

Player position changed.

New in version 0.10.

do_queue_cleared() virtual

All items were removed from queue.

Note that in such event [vfunc`Clapper`.Reactable.queue_item_removed] will NOT be called for each item for performance reasons. You probably want to implement this function if you also implemented item removal.

New in version 0.10.

do_queue_item_added(item, index) virtual
Parameters:

An item was added to the queue.

New in version 0.10.

do_queue_item_removed(item, index) virtual
Parameters:

An item was removed from queue.

Implementations that are interested in queue items removal should also implement [vfunc`Clapper`.Reactable.queue_cleared].

New in version 0.10.

do_queue_item_repositioned(before, after) virtual
Parameters:

An item changed position within queue.

New in version 0.10.

do_queue_progression_changed(mode) virtual
Parameters:

mode (Clapper.QueueProgressionMode) – a Clapper.QueueProgressionMode

Progression mode of the queue was changed.

New in version 0.10.

do_speed_changed(speed) virtual
Parameters:

speed (float) – the playback speed multiplier

Player speed changed.

New in version 0.10.

do_state_changed(state) virtual
Parameters:

state (Clapper.PlayerState) – a Clapper.PlayerState

Player state changed.

New in version 0.10.

do_volume_changed(volume) virtual
Parameters:

volume (float) – the volume level

Player volume changed.

New in version 0.10.