mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
API: add toggle_play method
This commit is contained in:
23
lib/gst/clapper/gstclapper.c
vendored
23
lib/gst/clapper/gstclapper.c
vendored
@@ -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)
|
||||
{
|
||||
|
3
lib/gst/clapper/gstclapper.h
vendored
3
lib/gst/clapper/gstclapper.h
vendored
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user