mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Merge branch 'video-stop' into 'master'
video: Stop playing when appropriate See merge request GNOME/gtk!3022
This commit is contained in:
commit
a7164208d3
@ -131,6 +131,9 @@ gtk_video_unrealize (GtkWidget *widget)
|
|||||||
{
|
{
|
||||||
GtkVideo *self = GTK_VIDEO (widget);
|
GtkVideo *self = GTK_VIDEO (widget);
|
||||||
|
|
||||||
|
if (self->autoplay && self->media_stream)
|
||||||
|
gtk_media_stream_pause (self->media_stream);
|
||||||
|
|
||||||
if (self->media_stream)
|
if (self->media_stream)
|
||||||
{
|
{
|
||||||
GdkSurface *surface;
|
GdkSurface *surface;
|
||||||
@ -149,7 +152,9 @@ gtk_video_map (GtkWidget *widget)
|
|||||||
|
|
||||||
GTK_WIDGET_CLASS (gtk_video_parent_class)->map (widget);
|
GTK_WIDGET_CLASS (gtk_video_parent_class)->map (widget);
|
||||||
|
|
||||||
if (self->autoplay && self->media_stream)
|
if (self->autoplay &&
|
||||||
|
self->media_stream &&
|
||||||
|
gtk_media_stream_is_prepared (self->media_stream))
|
||||||
gtk_media_stream_play (self->media_stream);
|
gtk_media_stream_play (self->media_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,11 +170,20 @@ gtk_video_unmap (GtkWidget *widget)
|
|||||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), FALSE);
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: pause video here? */
|
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gtk_video_parent_class)->unmap (widget);
|
GTK_WIDGET_CLASS (gtk_video_parent_class)->unmap (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_video_hide (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkVideo *self = GTK_VIDEO (widget);
|
||||||
|
|
||||||
|
if (self->autoplay && self->media_stream)
|
||||||
|
gtk_media_stream_pause (self->media_stream);
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (gtk_video_parent_class)->hide (widget);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_video_set_focus_child (GtkWidget *widget,
|
gtk_video_set_focus_child (GtkWidget *widget,
|
||||||
GtkWidget *child)
|
GtkWidget *child)
|
||||||
@ -268,6 +282,7 @@ gtk_video_class_init (GtkVideoClass *klass)
|
|||||||
widget_class->unrealize = gtk_video_unrealize;
|
widget_class->unrealize = gtk_video_unrealize;
|
||||||
widget_class->map = gtk_video_map;
|
widget_class->map = gtk_video_map;
|
||||||
widget_class->unmap = gtk_video_unmap;
|
widget_class->unmap = gtk_video_unmap;
|
||||||
|
widget_class->hide = gtk_video_hide;
|
||||||
widget_class->set_focus_child = gtk_video_set_focus_child;
|
widget_class->set_focus_child = gtk_video_set_focus_child;
|
||||||
|
|
||||||
gobject_class->dispose = gtk_video_dispose;
|
gobject_class->dispose = gtk_video_dispose;
|
||||||
@ -547,7 +562,9 @@ gtk_video_notify_cb (GtkMediaStream *stream,
|
|||||||
gtk_video_update_playing (self);
|
gtk_video_update_playing (self);
|
||||||
if (g_str_equal (pspec->name, "prepared"))
|
if (g_str_equal (pspec->name, "prepared"))
|
||||||
{
|
{
|
||||||
if (self->autoplay && gtk_media_stream_is_prepared (stream))
|
if (self->autoplay &&
|
||||||
|
gtk_media_stream_is_prepared (stream) &&
|
||||||
|
gtk_widget_get_mapped (GTK_WIDGET (self)))
|
||||||
gtk_media_stream_play (stream);
|
gtk_media_stream_play (stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -605,7 +622,9 @@ gtk_video_set_media_stream (GtkVideo *self,
|
|||||||
"notify",
|
"notify",
|
||||||
G_CALLBACK (gtk_video_notify_cb),
|
G_CALLBACK (gtk_video_notify_cb),
|
||||||
self);
|
self);
|
||||||
if (self->autoplay)
|
if (self->autoplay &&
|
||||||
|
gtk_media_stream_is_prepared (stream) &&
|
||||||
|
gtk_widget_get_mapped (GTK_WIDGET (self)))
|
||||||
gtk_media_stream_play (stream);
|
gtk_media_stream_play (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user