API: add toggle_play method

This commit is contained in:
Rafał Dzięgiel
2021-04-26 14:21:33 +02:00
parent e92ad68220
commit c6e8824e3b
3 changed files with 26 additions and 9 deletions

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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);