summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLionel Landwerlin <llandwerlin@gmail.com>2013-03-13 14:41:44 +0000
committerLionel Landwerlin <llandwerlin@gmail.com>2013-03-18 16:24:19 +0000
commit97458975c56eb658507ff2361b886efc91156cc7 (patch)
tree587b5d4e2bb9891317b41db78587f6d972eb6827 /examples
parent136c57cf198db7e58293212f2d7b9411e334fa1f (diff)
downloadclutter-gst-97458975c56eb658507ff2361b886efc91156cc7.tar.gz
examples: video-player: display video at right aspect ratio
Diffstat (limited to 'examples')
-rw-r--r--examples/video-player.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/examples/video-player.c b/examples/video-player.c
index 69c9364..539ab97 100644
--- a/examples/video-player.c
+++ b/examples/video-player.c
@@ -311,33 +311,30 @@ size_change (ClutterGstPlayer *player,
gfloat new_x, new_y, new_width, new_height;
gfloat stage_width, stage_height;
gfloat frame_width, frame_height;
+ gdouble frame_aspect, stage_aspect;
- clutter_actor_get_size (stage, &stage_width, &stage_height);
-
- /* base_width and base_height are the actual dimensions of the buffers before
- * taking the pixel aspect ratio into account. We need to get the actual
- * size of the actor to display */
- /* clutter_actor_get_size (app->vactor, &frame_width, &frame_height); */
frame_width = base_width;
frame_height = base_height;
- new_height = (frame_height * stage_width) / frame_width;
- if (new_height <= stage_height)
+ clutter_actor_get_size (stage, &stage_width, &stage_height);
+
+ frame_aspect = frame_width / frame_height;
+ stage_aspect = stage_width / stage_height;
+
+ if (stage_aspect < frame_aspect)
{
new_width = stage_width;
-
- new_x = 0;
- new_y = (stage_height - new_height) / 2;
+ new_height = stage_width / frame_aspect;
}
else
{
- new_width = (frame_width * stage_height) / frame_height;
new_height = stage_height;
-
- new_x = (stage_width - new_width) / 2;
- new_y = 0;
+ new_width = stage_height * frame_aspect;
}
+ new_x = (stage_width - new_width) / 2;
+ new_y = (stage_height - new_height) / 2;
+
clutter_actor_set_position (app->vactor, new_x, new_y);
clutter_actor_set_size (app->vactor, new_width, new_height);
}