clutter-gstreamer 2.2.4-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +70 -0
  3. data/lib/clutter-gst.rb +79 -0
  4. data/lib/clutter-gstreamer.rb +17 -0
  5. data/sample/media-actions-pause.png +0 -0
  6. data/sample/media-actions-start.png +0 -0
  7. data/sample/vid-panel.png +0 -0
  8. data/sample/video-player.rb +376 -0
  9. data/sample/video-sink-navigation.rb +98 -0
  10. data/sample/video-sink.rb +87 -0
  11. data/test/clutter-gstreamer-test-utils.rb +41 -0
  12. data/test/run-test.rb +63 -0
  13. data/test/test-clutter-gst.rb +26 -0
  14. data/vendor/local/bin/libclutter-gst-3.0-0.dll +0 -0
  15. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-aspectratio.h +105 -0
  16. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-camera-device.h +119 -0
  17. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-camera-manager.h +100 -0
  18. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-camera.h +206 -0
  19. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-content.h +107 -0
  20. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-crop.h +104 -0
  21. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-enum-types.h +23 -0
  22. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-playback.h +169 -0
  23. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-player.h +157 -0
  24. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-types.h +167 -0
  25. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-util.h +53 -0
  26. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-version.h +98 -0
  27. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst-video-sink.h +124 -0
  28. data/vendor/local/include/clutter-gst-3.0/clutter-gst/clutter-gst.h +47 -0
  29. data/vendor/local/lib/girepository-1.0/ClutterGst-3.0.typelib +0 -0
  30. data/vendor/local/lib/gstreamer-1.0/libgstclutter-3.0.dll +0 -0
  31. data/vendor/local/lib/gstreamer-1.0/libgstclutter-3.0.dll.a +0 -0
  32. data/vendor/local/lib/gstreamer-1.0/libgstclutter-3.0.la +41 -0
  33. data/vendor/local/lib/libclutter-gst-3.0.dll.a +0 -0
  34. data/vendor/local/lib/libclutter-gst-3.0.la +41 -0
  35. data/vendor/local/lib/pkgconfig/clutter-gst-3.0.pc +12 -0
  36. data/vendor/local/share/gir-1.0/ClutterGst-3.0.gir +3308 -0
  37. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstAspectratio.html +171 -0
  38. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstCamera.html +1528 -0
  39. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstCameraDevice.html +418 -0
  40. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstContent.html +551 -0
  41. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstCrop.html +198 -0
  42. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstPlayback.html +1559 -0
  43. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ClutterGstPlayer.html +805 -0
  44. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ch01.html +33 -0
  45. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ch02.html +42 -0
  46. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ch03.html +45 -0
  47. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ch04.html +35 -0
  48. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/ch05.html +39 -0
  49. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/clutter-gst-3.0.devhelp2 +197 -0
  50. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/clutter-gst-Utilities.html +316 -0
  51. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/clutter-gst-Versioning-Macros.html +176 -0
  52. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/clutter-gst-Video-Sink.html +560 -0
  53. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/home.png +0 -0
  54. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/index.html +98 -0
  55. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/index.sgml +273 -0
  56. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/left-insensitive.png +0 -0
  57. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/left.png +0 -0
  58. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/license.html +59 -0
  59. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/right-insensitive.png +0 -0
  60. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/right.png +0 -0
  61. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/style.css +476 -0
  62. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/up-insensitive.png +0 -0
  63. data/vendor/local/share/gtk-doc/html/clutter-gst-3.0/up.png +0 -0
  64. data/vendor/local/share/license/clutter-gst/AUTHORS +7 -0
  65. data/vendor/local/share/license/clutter-gst/COPYING +502 -0
  66. metadata +163 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af35acf4d3bdf7e616a8dc976fdea51fa9d7294f
4
+ data.tar.gz: 0145ccee1811519fb0e2c8d68124c9f9f8ad58d8
5
+ SHA512:
6
+ metadata.gz: 0280c072735ad4c200d55f9a08041f635c2d0bf7f83706d70c869f72fa53f4ed50a5f03c1b5a1c7af3fd1821c971268c3cf47361430eb5901d408e2d59b5e1bf
7
+ data.tar.gz: fe245f4b4c32a7814289b682e5e7f3689e5207d51480fef1296830fb074667732dbb6d37c0110455ecd34344da172f728a8763b3324478c9e1cc6fa7e4b56a91
data/Rakefile ADDED
@@ -0,0 +1,70 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ $LOAD_PATH.unshift("./../glib2/lib")
20
+ require "gnome2/rake/package-task"
21
+
22
+ package_task = GNOME2::Rake::PackageTask.new do |package|
23
+ package.summary = "Ruby/ClutterGStreamer is a Ruby binding of Clutter-GStreamer."
24
+ package.description = "Ruby/ClutterGStreamer is a Ruby binding of Clutter-GStreamer."
25
+ package.dependency.gem.runtime = ["gdk_pixbuf2", "clutter", "gstreamer"]
26
+ package.dependency.gem.development = ["test-unit-notify"]
27
+ package.windows.packages = []
28
+ package.windows.dependencies = []
29
+ package.windows.build_dependencies = [
30
+ "glib2",
31
+ "gdk_pixbuf2",
32
+ "atk",
33
+ "pango",
34
+ "gobject-introspection",
35
+ "clutter",
36
+ "gstreamer",
37
+ ]
38
+ package.windows.gobject_introspection_dependencies = [
39
+ "atk",
40
+ "pango",
41
+ "gdk_pixbuf2",
42
+ "clutter",
43
+ "gstreamer",
44
+ ]
45
+ package.external_packages = [
46
+ {
47
+ :name => "clutter-gst",
48
+ :download_site => :gnome,
49
+ :label => "Clutter-GStreamer",
50
+ :version => "3.0.0",
51
+ :compression_method => "xz",
52
+ :windows => {
53
+ :configure_args => [
54
+ "--enable-introspection",
55
+ ],
56
+ :built_file => "bin/libclutter-gst-3.0-0.dll",
57
+ },
58
+ }
59
+ ]
60
+ end
61
+ package_task.define
62
+
63
+ namespace :dependency do
64
+ desc "Install depenencies"
65
+ task :install do
66
+ # TODO: Install gir1.2-clutter-gst-1.0 on Debian.
67
+ end
68
+ end
69
+
70
+ task :build => "dependency:install"
@@ -0,0 +1,79 @@
1
+ # Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "gdk_pixbuf2"
18
+ require "clutter"
19
+ require "gst"
20
+
21
+ base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
22
+ vendor_dir = base_dir + "vendor" + "local"
23
+ vendor_bin_dir = vendor_dir + "bin"
24
+ GLib.prepend_dll_path(vendor_bin_dir)
25
+ vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0"
26
+ GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir)
27
+
28
+ module ClutterGst
29
+ LOG_DOMAIN = "Clutter-GStreamer"
30
+ GLib::Log.set_log_domain(LOG_DOMAIN)
31
+
32
+ class << self
33
+ def const_missing(name)
34
+ init
35
+ if const_defined?(name)
36
+ const_get(name)
37
+ else
38
+ super
39
+ end
40
+ end
41
+
42
+ def init(argv=[])
43
+ class << self
44
+ remove_method(:init)
45
+ remove_method(:const_missing)
46
+ end
47
+ Gst.init if Gst.respond_to?(:init)
48
+ Clutter.init if Clutter.respond_to?(:init)
49
+ loader = Loader.new(self, argv)
50
+ loader.load("ClutterGst")
51
+ end
52
+ end
53
+
54
+ class Loader < GObjectIntrospection::Loader
55
+ class InitError < StandardError
56
+ end
57
+
58
+ def initialize(base_module, init_arguments)
59
+ super(base_module)
60
+ @init_arguments = init_arguments
61
+ end
62
+
63
+ private
64
+ def pre_load(repository, namespace)
65
+ init = repository.find(namespace, "init")
66
+ arguments = [
67
+ [$0] + @init_arguments,
68
+ ]
69
+ error, returned_arguments = init.invoke(:arguments => arguments)
70
+ @init_arguments.replace(returned_arguments[1..-1])
71
+ if error.to_i <= 0
72
+ raise InitError, "failed to initialize Clutter-GStreamer: #{error.name}"
73
+ end
74
+ end
75
+
76
+ def post_load(repository, namespace)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,17 @@
1
+ # Copyright (C) 2014 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "clutter-gst"
Binary file
Binary file
Binary file
@@ -0,0 +1,376 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This sample code is a port of clutter-gst/examples/video-player.c. The
4
+ # image files used in this sample code are copied from clutter-gst/examples.
5
+ # They are licensed under the terms of the GNU Lesser General Public
6
+ # License, version 2.1 or (at your option) later.
7
+ #
8
+ # The original header:
9
+ # video-player.c - A simple video player with an OSD.
10
+ #
11
+ # Copyright (C) 2007,2008 OpenedHand
12
+ # Copyright (C) 2013 Collabora
13
+ #
14
+ # Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
15
+ #
16
+ # This library is free software; you can redistribute it and/or
17
+ # modify it under the terms of the GNU Lesser General Public
18
+ # License as published by the Free Software Foundation; either
19
+ # version 2.1 of the License, or (at your option) any later version.
20
+ #
21
+ # This library is distributed in the hope that it will be useful,
22
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
+ # Lesser General Public License for more details.
25
+ #
26
+ # You should have received a copy of the GNU Lesser General Public
27
+ # License along with this library; if not, write to the Free Software
28
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29
+
30
+ require "optparse"
31
+
32
+ require "clutter-gst"
33
+
34
+ SEEK_H = 14
35
+ SEEK_W = 440
36
+
37
+ GST_PLAY_FLAG_VIS = (1 << 3)
38
+
39
+ class VideoApp
40
+ attr_accessor :stage
41
+ attr_accessor :vtexture
42
+ attr_accessor :control, :control_bg, :control_label
43
+ attr_accessor :control_play, :control_pause
44
+ attr_accessor :control_seek1, :control_seek2, :control_seekbar
45
+ attr_accessor :controls_showing, :paused, :mouse_in_window
46
+ attr_accessor :controls_timeout
47
+ def initialize
48
+ @controls_showing = false
49
+ @paused = false
50
+ @mouse_in_window = false
51
+ @controls_timeout = 0
52
+ end
53
+ end
54
+
55
+ opt_fullscreen = false
56
+ opt_loop = false
57
+
58
+ parser = OptionParser.new
59
+ parser.on("-f", "--[no-]fullscreen",
60
+ "Start the player in fullscreen",
61
+ "(#{opt_fullscreen})") do |boolean|
62
+ opt_fullscreen = boolean
63
+ end
64
+ parser.on("-l", "--[no-]loop",
65
+ "Start the video again once reached EOS",
66
+ "(#{opt_loop})") do |boolean|
67
+ opt_loop = boolean
68
+ end
69
+ parser.parse!
70
+
71
+ def controls_timeout_cb(app)
72
+ app.controls_timeout = 0
73
+ show_controls(app, false)
74
+ false
75
+ end
76
+
77
+ def actor_animate(actor, mode, duration, first_property, *args)
78
+ actor.save_easing_state
79
+ actor.easing_mode = mode
80
+ actor.easing_duration = duration
81
+
82
+ actor.set_property(first_property, args.first)
83
+ end
84
+
85
+ def show_controls(app, vis)
86
+ return if app.control.nil?
87
+
88
+ if vis == true && app.controls_showing == true
89
+ if app.controls_timeout == 0
90
+ app.controls_timeout = GLib::Timeout.add_seconds(5) do
91
+ controls_timeout_cb(app)
92
+ end
93
+ end
94
+ return
95
+ end
96
+
97
+ if vis == true && app.controls_showing == false
98
+ app.controls_showing = true
99
+ app.stage.show_cursor
100
+ actor_animate(app.control, :ease_out_quint, 250, "opacity", 224)
101
+ return
102
+ end
103
+
104
+ if vis == false && app.controls_showing == true
105
+ app.controls_showing = false
106
+ if app.mouse_in_window
107
+ app.stage.hide_cursor
108
+ end
109
+ actor_animate(app.control, :ease_out_quint, 250, "opacity", 0)
110
+ return
111
+ end
112
+ end
113
+
114
+ def toggle_pause_state(app)
115
+ return if app.vtexture.nil?
116
+
117
+ if app.paused
118
+ app.vtexture.playing = true
119
+ app.paused = false
120
+ app.control_play.hide
121
+ app.control_pause.show
122
+ else
123
+ app.vtexture.playing = false
124
+ app.paused = true
125
+ app.control_pause.hide
126
+ app.control_play.show
127
+ end
128
+ end
129
+
130
+ def position_controls(app, controls)
131
+ stage_width, stage_height = app.stage.size
132
+ bg_width, bg_height = app.control.size
133
+
134
+ x = ((stage_width - bg_width) / 2).floor
135
+ y = stage_height - bg_height - 28
136
+
137
+ controls.set_position(x, y)
138
+ end
139
+
140
+ def new_rectangle_with_color(color)
141
+ actor = Clutter::Actor.new
142
+ actor.background_color = color
143
+ actor
144
+ end
145
+
146
+ stage_color = Clutter::Color.new(0, 0, 0, 0)
147
+ control_color1 = Clutter::Color.new(73, 74, 77, 0xee)
148
+ control_color2 = Clutter::Color.new(0xcc, 0xcc, 0xcc, 0xff)
149
+
150
+ if ARGV.length < 1
151
+ puts "Usage: #{$0} [OPTIONS] <video file> - A simple video player"
152
+ exit(false)
153
+ end
154
+
155
+ stage = Clutter::Stage.new
156
+ stage.background_color = Clutter::Color.new(0, 0, 0, 0)
157
+ stage.set_size(768, 576)
158
+ stage.set_minimum_size(640, 480)
159
+ stage.fullscreen = true if opt_fullscreen
160
+
161
+ app = VideoApp.new
162
+ app.stage = stage
163
+ app.vtexture = ClutterGst::VideoTexture.new
164
+
165
+ raise "failed to create vtexture" if app.vtexture.nil?
166
+
167
+ # By default ClutterGst seeks to the nearest key frame (faster). However
168
+ # it has the weird effect that when you click on the progress bar, the fill
169
+ # goes to the key frame position that can be quite far from where you
170
+ # clicked. Using the ACCURATE flag tells playbin2 to seek to the actual
171
+ # frame
172
+ app.vtexture.seek_flags = :accurate
173
+
174
+ app.vtexture.signal_connect("eos") do |media, app|
175
+ if opt_loop
176
+ media.progress = 0.0
177
+ media.playing = true
178
+ end
179
+ end
180
+
181
+ stage.signal_connect("allocation-changed") do |stage, box, flags|
182
+ position_controls(app, app.control)
183
+ show_controls(app, true)
184
+ end
185
+
186
+ stage.signal_connect("destroy") do
187
+ Clutter.main_quit
188
+ end
189
+
190
+ # Handle it ourselves so can scale up for fullscreen better
191
+ app.vtexture.signal_connect_after("size-change") do |texture, base_width, base_height|
192
+ stage_width, stage_height = stage.size
193
+
194
+ # base_width and base_height are the actual dimensions of the buffers before
195
+ # taking the pixel aspect ratio into account. We need to get the actual
196
+ # size of the texture to display
197
+ frame_width, frame_height = texture.size
198
+
199
+ new_height = (frame_height * stage_width) / frame_width
200
+ if new_height <= stage_height
201
+ new_width = stage_width
202
+ new_x = 0
203
+ new_y = (stage_height - new_height) / 2
204
+ else
205
+ new_width = (frame_width * stage_height) / frame_height
206
+ new_height = stage_height
207
+ new_x = (stage_width - new_width) / 2
208
+ new_y = 0
209
+ end
210
+ texture.set_position(new_x, new_y)
211
+ texture.set_size(new_width, new_height)
212
+ end
213
+
214
+ # Load up out video texture
215
+ app.vtexture.filename = ARGV[0]
216
+
217
+ # Set up things so that a visualisation is played if there's no video
218
+ pipe = app.vtexture.pipeline
219
+ raise "Unable to get gstreamer pipeline!" unless pipe
220
+
221
+ iter = pipe.iterate_sinks
222
+ raise "Unable to iterate over sinks!" unless iter
223
+
224
+ playsink = nil
225
+ while (value = iter.next)[0] == :ok
226
+ playsink = value[1].value
227
+ sink_name = playsink.name # unused
228
+ end
229
+
230
+ goomsource = Gst::ElementFactory.make("goom", "source")
231
+ raise "Unable to create goom visualiser!" unless goomsource
232
+
233
+ # TODO: warnings occurred
234
+ #playsink_flags = playsink.flags.value
235
+ #playsink_flags |= GST_PLAY_FLAG_VIS
236
+ playsink.vis_plugin = goomsource
237
+ #playsink.flags = playsink_flags
238
+
239
+ # Create the control UI
240
+ app.control = Clutter::Actor.new
241
+
242
+ app.control_bg = Clutter::Texture.new
243
+ app.control_bg.from_file = File.expand_path("vid-panel.png", File.dirname(__FILE__))
244
+ app.control_play = Clutter::Texture.new
245
+ app.control_play.from_file = File.expand_path("media-actions-start.png", File.dirname(__FILE__))
246
+ app.control_pause = Clutter::Texture.new
247
+ app.control_pause.from_file = File.expand_path("media-actions-pause.png", File.dirname(__FILE__))
248
+
249
+ app.control_seek1 = new_rectangle_with_color(control_color1)
250
+ app.control_seek2 = new_rectangle_with_color(control_color2)
251
+ app.control_seekbar = new_rectangle_with_color(control_color1)
252
+ app.control_seekbar.opacity = 0x99
253
+
254
+ app.control_label = Clutter::Text.new
255
+ app.control_label.font_name = "Sans Bold 14"
256
+ app.control_label.text = File.basename(ARGV[0])
257
+ stage.title = File.basename(ARGV[0]) # substitutes for label text
258
+ app.control_label.color = control_color1
259
+
260
+ app.control_play.hide
261
+
262
+ app.control.add_child(app.control_bg)
263
+ app.control.add_child(app.control_play)
264
+ app.control.add_child(app.control_pause)
265
+ app.control.add_child(app.control_seek1)
266
+ app.control.add_child(app.control_seek2)
267
+ app.control.add_child(app.control_seekbar)
268
+ app.control.add_child(app.control_label)
269
+
270
+ app.control.opacity = 0xee
271
+
272
+ app.control_play.set_position(22, 31)
273
+ app.control_pause.set_position(18, 31)
274
+
275
+ app.control_seek1.set_size(SEEK_W + 4, SEEK_H + 4)
276
+ app.control_seek1.set_position(80, 57)
277
+ app.control_seek2.set_size(SEEK_W, SEEK_H)
278
+ app.control_seek2.set_position(82, 59)
279
+ app.control_seekbar.set_size(0, SEEK_H)
280
+ app.control_seekbar.set_position(82, 59)
281
+
282
+ app.control_label.set_position(82, 29)
283
+
284
+ # Add control UI to stage
285
+ stage.add_child(app.vtexture)
286
+ stage.add_child(app.control)
287
+
288
+ position_controls(app, app.control)
289
+
290
+ stage.hide_cursor
291
+ actor_animate(app.control, :ease_out_quint, 1000, "opacity", 0)
292
+
293
+ # Hook up other events
294
+ stage.signal_connect("event") do |stage, event|
295
+ handled = false
296
+
297
+ case event.type
298
+ when Clutter::EventType::MOTION
299
+ show_controls(app, true)
300
+ handled = true
301
+ when Clutter::EventType::BUTTON_PRESS
302
+ if app.controls_showing
303
+ actor = stage.get_actor_at_pos(:all, event.x, event.y)
304
+ if actor == app.control_pause || actor == app.control_play
305
+ toggle_pause_state(app)
306
+ elsif actor == app.control_seek1 ||
307
+ actor == app.control_seek2 ||
308
+ actor == app.control_seekbar
309
+ x, y = app.control_seekbar.transformed_position
310
+ dist = event.x - x
311
+ def clamp(x, low, high)
312
+ if x > high
313
+ high
314
+ elsif x < low
315
+ low
316
+ else
317
+ x
318
+ end
319
+ end
320
+ dist = clamp(dist, 0, SEEK_W)
321
+ progress = 1.0 * dist / SEEK_W
322
+ app.vtexture.progress == progress
323
+ end
324
+ end
325
+ handled = true
326
+ when Clutter::EventType::KEY_PRESS
327
+ animation = nil
328
+ case event.key_symbol
329
+ when Clutter::Keys::KEY_d
330
+ if app.vtexture
331
+ app.stage.remove_child(app.vtexture)
332
+ app.vtexture = nil
333
+ end
334
+ if app.control
335
+ app.stage.remove_child(app.control)
336
+ app.control = nil
337
+ end
338
+ when Clutter::Keys::KEY_q, Clutter::Keys::KEY_Escape
339
+ app.stage.destroy
340
+ when Clutter::Keys::KEY_e
341
+ if app.vtexture
342
+ app.vtexture .set_pivot_point(0.5, 0)
343
+ animation = actor_animate(app.vtexture,
344
+ :linear, 500,
345
+ "rotation-angle-y", 360.0)
346
+ animation.signal_connect_after("transitions-completed") do
347
+ if app.vtexture
348
+ app.vtexture.set_rotation_angle(:y_axis, 0.0)
349
+ end
350
+ end
351
+ handled = true
352
+ end
353
+ else
354
+ toggle_pause_state(app)
355
+ handled = true
356
+ end
357
+ when Clutter::EventType::ENTER
358
+ app.mouse_in_window = true
359
+ app.stage.cursor_visible = app.controls_showing
360
+ when Clutter::EventType::LEAVE
361
+ app.mouse_in_window = false
362
+ app.stage.show_cursor
363
+ end
364
+ handled
365
+ end
366
+
367
+ app.vtexture.signal_connect("notify::progress") do |video_texture, pspec|
368
+ progress = video_texture.progress
369
+ app.control_seekbar.set_size(progress * SEEK_W, SEEK_H)
370
+ end
371
+
372
+ app.vtexture.playing = true
373
+
374
+ stage.show
375
+
376
+ Clutter.main