diff --git a/lib/gst/clapper/gstclapper.c b/lib/gst/clapper/gstclapper.c index db14cd20..bd179f72 100644 --- a/lib/gst/clapper/gstclapper.c +++ b/lib/gst/clapper/gstclapper.c @@ -3168,6 +3168,29 @@ gst_clapper_pause (GstClapper * self) } } +/** + * gst_clapper_toggle_play: + * @clapper: #GstClapper instance + * + * Toggle between play and pause on the loaded stream. + * This function does nothing if player is stopped. + */ +void +gst_clapper_toggle_play (GstClapper * self) +{ + g_return_if_fail (GST_IS_CLAPPER (self)); + + if (self->app_state == GST_CLAPPER_STATE_STOPPED) { + GST_DEBUG_OBJECT (self, "Player stopped, toggle_play ignored"); + return; + } + + if (self->app_state == GST_CLAPPER_STATE_PLAYING) + gst_clapper_pause (self); + else + gst_clapper_play (self); +} + static void gst_clapper_stop_internal (GstClapper * self, gboolean transient) { diff --git a/lib/gst/clapper/gstclapper.h b/lib/gst/clapper/gstclapper.h index 173ad9f9..44bb20b0 100644 --- a/lib/gst/clapper/gstclapper.h +++ b/lib/gst/clapper/gstclapper.h @@ -161,6 +161,9 @@ void gst_clapper_play (GstClapper *clapper GST_CLAPPER_API void gst_clapper_pause (GstClapper *clapper); +GST_CLAPPER_API +void gst_clapper_toggle_play (GstClapper *clapper); + GST_CLAPPER_API void gst_clapper_stop (GstClapper *clapper); diff --git a/src/player.js b/src/player.js index 3cbc1e26..6c384d38 100644 --- a/src/player.js +++ b/src/player.js @@ -355,15 +355,6 @@ class ClapperPlayer extends GstClapper.Clapper controls.volumeScale.set_value(volume); } - toggle_play() - { - const action = (this.state === GstClapper.ClapperState.PLAYING) - ? 'pause' - : 'play'; - - this[action](); - } - next_chapter() { return this._switchChapter(false);