summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-26 21:53:39 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-26 21:53:39 +0000
commit1ca526c62d60a418fc3feb0c288bf502ea3e1593 (patch)
treecee373920012f4d71395924a5fc1934dfa90e035
parent340c3df3302bf6c362f8e13792a09def7e8db0a3 (diff)
Python efl: emotion fully documented, no functional changes, but used the elm properties-on-top style
SVN revision: 84389
-rw-r--r--doc/ecore/ecore.rst1
-rw-r--r--doc/edje/edje.rst1
-rw-r--r--doc/emotion/emotion.rst19
-rw-r--r--doc/evas/evas.rst1
-rw-r--r--efl/emotion/efl.emotion.pyx646
5 files changed, 490 insertions, 178 deletions
diff --git a/doc/ecore/ecore.rst b/doc/ecore/ecore.rst
index 5d77cdd..d66453f 100644
--- a/doc/ecore/ecore.rst
+++ b/doc/ecore/ecore.rst
@@ -1,6 +1,7 @@
1:mod:`efl.ecore` Module 1:mod:`efl.ecore` Module
2======================= 2=======================
3 3
4.. module:: efl.ecore
4 5
5What is Ecore? 6What is Ecore?
6-------------- 7--------------
diff --git a/doc/edje/edje.rst b/doc/edje/edje.rst
index 0643e4c..ac3f056 100644
--- a/doc/edje/edje.rst
+++ b/doc/edje/edje.rst
@@ -1,6 +1,7 @@
1:mod:`efl.edje` Module 1:mod:`efl.edje` Module
2======================= 2=======================
3 3
4.. module:: efl.edje
4 5
5What is Edje? 6What is Edje?
6-------------- 7--------------
diff --git a/doc/emotion/emotion.rst b/doc/emotion/emotion.rst
index 4cb955f..963fa95 100644
--- a/doc/emotion/emotion.rst
+++ b/doc/emotion/emotion.rst
@@ -1,7 +1,7 @@
1:mod:`efl.emotion` Module 1:mod:`efl.emotion` Module
2========================= 2============================
3 3
4.. automodule:: efl.emotion 4.. module:: efl.emotion
5 5
6What is Emotion? 6What is Emotion?
7---------------- 7----------------
@@ -56,14 +56,24 @@ being sent, like "playback_started" or "open_done".
56.. rubric:: Available signals 56.. rubric:: Available signals
57 57
58The Evas_Object returned by emotion_object_add() has a number of signals that 58The Evas_Object returned by emotion_object_add() has a number of signals that
59can be listened to using evas' smart callbacks mechanism. All signals have 59can be listened to using evas' smart callbacks mechanism. The following is
60NULL as event info. The following is a list of interesting signals: 60a list of interesting signals:
61
61 - ``playback_started`` Emitted when the playback starts 62 - ``playback_started`` Emitted when the playback starts
62 - ``playback_finished`` Emitted when the playback finishes 63 - ``playback_finished`` Emitted when the playback finishes
63 - ``frame_decode`` Emitted every time a frame is decoded 64 - ``frame_decode`` Emitted every time a frame is decoded
65 - ``frame_resize`` Emitted when the frame change its size
64 - ``open_done`` Emitted when the media file is opened 66 - ``open_done`` Emitted when the media file is opened
65 - ``position_update`` Emitted when emotion_object_position_set is called 67 - ``position_update`` Emitted when emotion_object_position_set is called
68 - ``audio_level_change`` Emitted when the volume change it's value
66 - ``decode_stop`` Emitted after the last frame is decoded 69 - ``decode_stop`` Emitted after the last frame is decoded
70 - ``length_change`` Emitted if the media change it's size
71 - ``channels_change`` Emitted when the number of channels change
72 - ``title_change`` Emitted when the title change (?)
73 - ``progress_change``
74 - ``ref_change``
75 - ``button_num_change``
76 - ``button_change``
67 77
68 78
69Reference 79Reference
@@ -82,3 +92,4 @@ Inheritance diagram
82 efl.emotion 92 efl.emotion
83 :parts: 2 93 :parts: 2
84 94
95
diff --git a/doc/evas/evas.rst b/doc/evas/evas.rst
index 8b5f856..2e9ce1a 100644
--- a/doc/evas/evas.rst
+++ b/doc/evas/evas.rst
@@ -1,6 +1,7 @@
1:mod:`efl.evas` Module 1:mod:`efl.evas` Module
2====================== 2======================
3 3
4.. module:: efl.evas
4 5
5What is Evas? 6What is Evas?
6------------- 7-------------
diff --git a/efl/emotion/efl.emotion.pyx b/efl/emotion/efl.emotion.pyx
index f30a1e9..7d7a4df 100644
--- a/efl/emotion/efl.emotion.pyx
+++ b/efl/emotion/efl.emotion.pyx
@@ -15,7 +15,7 @@
15# You should have received a copy of the GNU Lesser General Public License 15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17 17
18from efl.eo cimport const_char_ptr 18from efl.eo cimport const_char_ptr, _ctouni, _cfruni
19from efl.eo cimport object_from_instance, _object_mapping_register 19from efl.eo cimport object_from_instance, _object_mapping_register
20from efl.evas cimport Evas_Object, Canvas 20from efl.evas cimport Evas_Object, Canvas
21from efl.evas cimport Object as evasObject 21from efl.evas cimport Object as evasObject
@@ -109,18 +109,19 @@ def shutdown():
109 109
110 110
111cdef class Emotion(evasObject): 111cdef class Emotion(evasObject):
112 """ 112 """ The emotion object
113 113
114 The emotion object 114 :see: :py:mod:`The documentation page<efl.emotion>`
115
116 :param evas: The canvas where the object will be added to.
117 :return: The emotion object just created.
118
119 The object can be manipulated as any other Evas object, using the
120 default efl.evas.Object manipulation functions.
121 115
122 The next step is to open the desired file with file_set(), and 116 :param evas: The canvas where the object will be added to.
123 start playing it with play_set(). 117 :type evas: efl.evas.Canvas
118 :param module_name: name of the engien to use (gstreamer, xine, vlc or generic)
119 :param module_params: Extra parameters, module specific
120 :param size: (w, h)
121 :param pos: (x, y)
122 :param geometry: (x, y, w, h)
123 :param color: (r, g, b, a)
124 :return: The emotion object instance just created.
124 125
125 """ 126 """
126 def __cinit__(self, *a, **ka): 127 def __cinit__(self, *a, **ka):
@@ -172,336 +173,570 @@ cdef class Emotion(evasObject):
172 self.layer_get(), self.clip_get(), self.visible_get(), 173 self.layer_get(), self.clip_get(), self.visible_get(),
173 evasObject.__repr__(self)) 174 evasObject.__repr__(self))
174 175
175 def file_get(self): 176 property file:
176 cdef const_char_ptr f 177 """ The filename of the file associated with the emotion object.
177 f = emotion_object_file_get(self.obj)
178 if f != NULL:
179 return f
180 178
181 def file_set(self, char *value): 179 The file to be used with this emotion object. If the
182 emotion_object_file_set(self.obj, value) 180 object already has another file set, this file will be unset and unloaded,
181 and the new file will be loaded to this emotion object. The seek position
182 will be set to 0, and the emotion object will be paused, instead of playing.
183
184 If there was already a filename set, and it's the same as the one being set
185 now, setting the property does nothing
183 186
184 property file: 187 Set to *None* if you want to unload the current file but don't
188 want to load anything else.
189
190 :type: str
191 """
185 def __get__(self): 192 def __get__(self):
186 return self.file_get() 193 return _ctouni(emotion_object_file_get(self.obj))
187 194
188 def __set__(self, char *value): 195 def __set__(self, char *value):
189 self.file_set(value) 196 emotion_object_file_set(self.obj, _cfruni(value))
197
198 def file_get(self):
199 return _ctouni(emotion_object_file_get(self.obj))
200 def file_set(self, char *file_name):
201 emotion_object_file_set(self.obj, _cfruni(file_name))
202
203 property play:
204 """ The play/pause state of the emotion object.
205
206 :type: bool
207 """
208 def __get__(self):
209 return bool(emotion_object_play_get(self.obj))
210
211 def __set__(self, int value):
212 emotion_object_play_set(self.obj, value)
190 213
191 def play_get(self): 214 def play_get(self):
192 return bool(emotion_object_play_get(self.obj)) 215 return bool(emotion_object_play_get(self.obj))
193
194 def play_set(self, int value): 216 def play_set(self, int value):
195 emotion_object_play_set(self.obj, value) 217 emotion_object_play_set(self.obj, value)
196 218
197 property play: 219 property position:
220 """ The position in the media file.
221
222 The current position of the media file to *sec*, this
223 only works on seekable streams. Setting the position doesn't change the
224 playing state of the media file.
225
226 :type: float
227 """
198 def __get__(self): 228 def __get__(self):
199 return self.play_get() 229 return emotion_object_position_get(self.obj)
200 230
201 def __set__(self, int value): 231 def __set__(self, double value):
202 self.play_set(value) 232 emotion_object_position_set(self.obj, value)
203 233
204 def position_get(self): 234 def position_get(self):
205 return emotion_object_position_get(self.obj) 235 return emotion_object_position_get(self.obj)
206
207 def position_set(self, double value): 236 def position_set(self, double value):
208 emotion_object_position_set(self.obj, value) 237 emotion_object_position_set(self.obj, value)
209 238
210 property position: 239 property buffer_size:
211 def __get__(self): 240 """ The percentual size of the buffering cache.
212 return self.position_get()
213 241
214 def __set__(self, double value): 242 The buffer size is given as a number between 0.0 and 1.0, 0.0 means
215 self.position_set(value) 243 the buffer if empty, 1.0 means full.
244 If no buffering is in progress 1.0 is returned. In all other cases (maybe
245 the backend don't support buffering) 1.0 is returned, thus you can always
246 check for buffer_size < 1.0 to know if buffering is in progress.
247
248 :type: float
249 """
250 def __get__(self):
251 return emotion_object_buffer_size_get(self.obj)
216 252
217 def buffer_size_get(self): 253 def buffer_size_get(self):
218 return emotion_object_buffer_size_get(self.obj) 254 return emotion_object_buffer_size_get(self.obj)
219 255
220 property buffer_size: 256 property video_handled:
257 """ True if the loaded stream contain at least one video track
258
259 :type: bool
260 """
221 def __get__(self): 261 def __get__(self):
222 return self.buffer_size_get() 262 return bool(emotion_object_video_handled_get(self.obj))
223 263
224 def video_handled_get(self): 264 def video_handled_get(self):
225 return bool(emotion_object_video_handled_get(self.obj)) 265 return bool(emotion_object_video_handled_get(self.obj))
226 266
227 property video_handled: 267 property audio_handled:
268 """ True if the loaded stream contain at least one audio track
269
270 :type: bool
271 """
228 def __get__(self): 272 def __get__(self):
229 return self.video_handled_get() 273 return bool(emotion_object_audio_handled_get(self.obj))
230 274
231 def audio_handled_get(self): 275 def audio_handled_get(self):
232 return bool(emotion_object_audio_handled_get(self.obj)) 276 return bool(emotion_object_audio_handled_get(self.obj))
233 277
234 property audio_handled: 278 property seekable:
279 """ Whether the media file is seekable.
280
281 :rtype: bool
282 """
235 def __get__(self): 283 def __get__(self):
236 return self.audio_handled_get() 284 return bool(emotion_object_seekable_get(self.obj))
237 285
238 def seekable_get(self): 286 def seekable_get(self):
239 return bool(emotion_object_seekable_get(self.obj)) 287 return bool(emotion_object_seekable_get(self.obj))
240 288
241 property seekable: 289 property play_length:
290 """ The length of play for the media file.
291
292 The total length of the media file in seconds.
293
294 :type: float
295 """
242 def __get__(self): 296 def __get__(self):
243 return self.seekable_get() 297 return emotion_object_play_length_get(self.obj)
244 298
245 def play_length_get(self): 299 def play_length_get(self):
246 return emotion_object_play_length_get(self.obj) 300 return emotion_object_play_length_get(self.obj)
247 301
248 property play_length: 302 property play_speed:
303 """ The play speed of the media file.
304
305 This sets the speed with which the media file will be played. 1.0
306 represents the normal speed, 2 double speed, 0.5 half speed and so on.
307
308 :type: float
309 """
310 def __get__(self):
311 return emotion_object_play_speed_get(self.obj)
312
313 def __set__(self, double value):
314 emotion_object_play_speed_set(self.obj, value)
315
316 def play_speed_get(self):
317 return emotion_object_play_speed_get(self.obj)
318 def play_speed_set(self, double value):
319 emotion_object_play_speed_set(self.obj, value)
320
321 property image_size:
322 """ The video size of the loaded file.
323
324 This is the reported size of the loaded video file. If a file
325 that doesn't contain a video channel is loaded, then this size can be
326 ignored.
327 The value reported by this function should be consistent with the aspect
328 ratio returned by :py:func:`ratio_get`, but sometimes the information
329 stored in the file is wrong. So use the ratio size reported by
330 py:func:`ratio_get()`, since it is more likely going to be accurate.
331
332 :type: tuple of int (w, h)
333 """
249 def __get__(self): 334 def __get__(self):
250 return self.play_length_get() 335 return self.image_size_get()
251 336
252 def image_size_get(self): 337 def image_size_get(self):
253 cdef int w, h 338 cdef int w, h
254 emotion_object_size_get(self.obj, &w, &h) 339 emotion_object_size_get(self.obj, &w, &h)
255 return (w, h) 340 return (w, h)
256 341
257 property image_size: 342 property smooth_scale:
343 """ Whether to use of high-quality image scaling algorithm
344 of the given video object.
345
346 When enabled, a higher quality video scaling algorithm is used when
347 scaling videos to sizes other than the source video. This gives
348 better results but is more computationally expensive.
349
350 :type: bool
351 """
258 def __get__(self): 352 def __get__(self):
259 return self.image_size_get() 353 return self.smooth_scale_get()
354
355 def __set__(self, int value):
356 self.smooth_scale_set(value)
260 357
261 def smooth_scale_get(self): 358 def smooth_scale_get(self):
262 return bool(emotion_object_smooth_scale_get(self.obj)) 359 return bool(emotion_object_smooth_scale_get(self.obj))
263
264 def smooth_scale_set(self, int value): 360 def smooth_scale_set(self, int value):
265 emotion_object_smooth_scale_set(self.obj, value) 361 emotion_object_smooth_scale_set(self.obj, value)
266 362
267 property smooth_scale: 363 property ratio:
364 """ The video aspect ratio of the media file loaded.
365
366 This function returns the video aspect ratio (width / height) of the file
367 loaded. It can be used to adapt the size of the emotion object in the canvas,
368 so the aspect won't be changed (by wrongly resizing the object). Or to crop
369 the video correctly, if necessary.
370
371 The described behavior can be applied like following. Consider a given
372 emotion object that we want to position inside an area, which we will
373 represent by *w* and *h*. Since we want to position this object either
374 stretching, or filling the entire area but overflowing the video, or just
375 adjust the video to fit inside the area without keeping the aspect ratio, we
376 must compare the video aspect ratio with the area aspect ratio::
377
378 w = 200; h = 300; # an arbitrary value which represents the area where
379 # the video would be placed
380 obj = Emotion(...)
381 r = w / h
382 vr = obj.ratio
383
384 Now, if we want to make the video fit inside the area, the following code
385 would do it::
386
387 if vr > r: # the video is wider than the area
388 vw = w
389 vh = w / vr
390 else: # the video is taller than the area
391 vh = h
392 vw = h * vr
393 obj.size = (vw, vh)
394
395 And for keeping the aspect ratio but making the video fill the entire area,
396 overflowing the content which can't fit inside it, we would do::
397
398 if vr > r: # the video is wider than the area
399 vh = h
400 vw = h * vr
401 else: # the video is taller than the area
402 vw = w
403 vh = w / vr
404 obj.size = (vw, vh)
405
406 Finally, by just resizing the video to the video area, we would have the
407 video stretched::
408
409 vw = w
410 vh = h
411 obj.size = (vw, vh)
412
413 .. note:: This function returns the aspect ratio that the video *should* be, but
414 sometimes the reported size from emotion_object_size_get() represents a
415 different aspect ratio. You can safely resize the video to respect the aspect
416 ratio returned by *this* function.
417
418 :type: float
419 """
268 def __get__(self): 420 def __get__(self):
269 return self.smooth_scale_get() 421 return emotion_object_ratio_get(self.obj)
270
271 def __set__(self, int value):
272 self.smooth_scale_set(value)
273 422
274 def ratio_get(self): 423 def ratio_get(self):
275 return emotion_object_ratio_get(self.obj) 424 return emotion_object_ratio_get(self.obj)
276 425
277 property ratio: 426 property audio_volume:
427 """ The audio volume.
428
429 The current value for the audio volume level. Range is from 0.0 to 1.0.
430
431 Sets the audio volume of the stream being played. This has nothing to do with
432 the system volume. This volume will be multiplied by the system volume. e.g.:
433 if the current volume level is 0.5, and the system volume is 50%, it will be
434 * 0.5 * 0.5 = 0.25.
435
436 .. note:: The default value depends on the module used. This value
437 doesn't get changed when another file is loaded.
438
439 :type: float
440 """
278 def __get__(self): 441 def __get__(self):
279 return self.ratio_get() 442 return emotion_object_audio_volume_get(self.obj)
280 443
281 def event_simple_send(self, int event_id): 444 def __set__(self, double value):
282 emotion_object_event_simple_send(self.obj, <Emotion_Event>event_id) 445 emotion_object_audio_volume_set(self.obj, value)
283 446
284 def audio_volume_get(self): 447 def audio_volume_get(self):
285 return emotion_object_audio_volume_get(self.obj) 448 return emotion_object_audio_volume_get(self.obj)
286
287 def audio_volume_set(self, double value): 449 def audio_volume_set(self, double value):
288 emotion_object_audio_volume_set(self.obj, value) 450 emotion_object_audio_volume_set(self.obj, value)
289 451
290 property audio_volume: 452 property audio_mute:
453 """ The mute audio option for this object.
454
455 :type: bool
456 """
291 def __get__(self): 457 def __get__(self):
292 return self.audio_volume_get() 458 return bool(emotion_object_audio_mute_get(self.obj))
293 459
294 def __set__(self, double value): 460 def __set__(self, int value):
295 self.audio_volume_set(value) 461 emotion_object_audio_mute_set(self.obj, bool(value))
296 462
297 def audio_mute_get(self): 463 def audio_mute_get(self):
298 return emotion_object_audio_mute_get(self.obj) 464 return emotion_object_audio_mute_get(self.obj)
299
300 def audio_mute_set(self, int value): 465 def audio_mute_set(self, int value):
301 emotion_object_audio_mute_set(self.obj, value) 466 emotion_object_audio_mute_set(self.obj, value)
302 467
303 property audio_mute: 468 property video_mute:
469 """ The mute video option for this object.
470
471 :type: bool
472 """
473 def __get__(self):
474 return emotion_object_video_mute_get(self.obj)
475
476 def __set__(self, int value):
477 emotion_object_video_mute_set(self.obj, value)
478
479 def video_mute_get(self):
480 return emotion_object_video_mute_get(self.obj)
481 def video_mute_set(self, int value):
482 emotion_object_video_mute_set(self.obj, value)
483
484 property spu_mute:
485 """ The SPU muted state.
486
487 :type: bool
488 """
304 def __get__(self): 489 def __get__(self):
305 return self.audio_mute_get() 490 return bool(emotion_object_spu_mute_get(self.obj))
306 491
307 def __set__(self, int value): 492 def __set__(self, int value):
308 self.audio_mute_set(value) 493 emotion_object_spu_mute_set(self.obj, bool(value))
494
495 def spu_mute_get(self):
496 return bool(emotion_object_spu_mute_get(self.obj))
497 def spu_mute_set(self, int value):
498 emotion_object_spu_mute_set(self.obj, bool(value))
309 499
310 def audio_channel_count(self): 500 def audio_channel_count(self):
501 """ Get the number of audio channels available in the loaded media.
502
503 :return: the number of channels
504 :rtype: int
505 """
311 return emotion_object_audio_channel_count(self.obj) 506 return emotion_object_audio_channel_count(self.obj)
312 507
313 def audio_channel_name_get(self, int channel): 508 def audio_channel_name_get(self, int channel):
314 cdef const_char_ptr n 509 """ Get the name of the given channel.
315 n = emotion_object_audio_channel_name_get(self.obj, channel) 510
316 if n != NULL: 511 :return: the name
317 return n 512 :rtype: str
513 """
514 return _ctouni(emotion_object_audio_channel_name_get(self.obj, channel))
515
516 property audio_channel:
517 """ The currently selected audio channel.
518
519 :type: int
520 """
521 def __get__(self):
522 return emotion_object_audio_channel_get(self.obj)
523
524 def __set__(self, int value):
525 emotion_object_audio_channel_set(self.obj, value)
318 526
319 def audio_channel_get(self): 527 def audio_channel_get(self):
320 return emotion_object_audio_channel_get(self.obj) 528 return emotion_object_audio_channel_get(self.obj)
321
322 def audio_channel_set(self, int channel): 529 def audio_channel_set(self, int channel):
323 emotion_object_audio_channel_set(self.obj, channel) 530 emotion_object_audio_channel_set(self.obj, channel)
324 531
325 property audio_channel: 532 def video_channel_count(self):
326 def __get__(self): 533 """ Get the number of video channels available in the loaded media.
327 return self.audio_channel_get()
328 534
329 def __set__(self, int value): 535 :return: the number of channels
330 self.audio_channel_set(value) 536 :rtype: int
537 """
538 return emotion_object_video_channel_count(self.obj)
331 539
332 def video_mute_get(self): 540 def video_channel_name_get(self, int channel):
333 return emotion_object_video_mute_get(self.obj) 541 """ Get the name of the given channel.
334 542
335 def video_mute_set(self, int value): 543 :return: the name
336 emotion_object_video_mute_set(self.obj, value) 544 :rtype: str
545 """
546 return _ctouni(emotion_object_video_channel_name_get(self.obj, channel))
337 547
338 property video_mute: 548 property video_channel:
549 """ The currently selected video channel.
550
551 :type: int
552 """
339 def __get__(self): 553 def __get__(self):
340 return self.video_mute_get() 554 return emotion_object_video_channel_get(self.obj)
341 555
342 def __set__(self, int value): 556 def __set__(self, int value):
343 self.video_mute_set(value) 557 emotion_object_video_channel_set(self.obj, value)
344
345 def video_channel_count(self):
346 return emotion_object_video_channel_count(self.obj)
347
348 def video_channel_name_get(self, int channel):
349 cdef const_char_ptr n
350 n = emotion_object_video_channel_name_get(self.obj, channel)
351 if n != NULL:
352 return n
353 558
354 def video_channel_get(self): 559 def video_channel_get(self):
355 return emotion_object_video_channel_get(self.obj) 560 return emotion_object_video_channel_get(self.obj)
356
357 def video_channel_set(self, int value): 561 def video_channel_set(self, int value):
358 emotion_object_video_channel_set(self.obj, value) 562 emotion_object_video_channel_set(self.obj, value)
359 563
360 property video_channel: 564 def spu_channel_count(self):
361 def __get__(self): 565 """ Get the number of SPU channels available in the loaded media.
362 return self.video_channel_get()
363 566
364 def __set__(self, int value): 567 :return: the number of channels
365 self.video_channel_set(value) 568 :rtype: int
569 """
570 return emotion_object_spu_channel_count(self.obj)
366 571
367 def spu_mute_get(self): 572 def spu_channel_name_get(self, int channel):
368 return emotion_object_spu_mute_get(self.obj) 573 """ Get the name of the given channel.
369 574
370 def spu_mute_set(self, int value): 575 :return: the name
371 emotion_object_spu_mute_set(self.obj, value) 576 :rtype: str
577 """
578 return _ctouni(emotion_object_spu_channel_name_get(self.obj, channel))
372 579
373 property spu_mute: 580 property spu_channel:
581 """ The currently selected SPU channel.
582
583 :type: int
584 """
374 def __get__(self): 585 def __get__(self):
375 return self.spu_mute_get() 586 return emotion_object_spu_channel_get(self.obj)
376 587
377 def __set__(self, int value): 588 def __set__(self, int value):
378 self.spu_mute_set(value) 589 emotion_object_spu_channel_set(self.obj, value)
379
380 def spu_channel_count(self):
381 return emotion_object_spu_channel_count(self.obj)
382
383 def spu_channel_name_get(self, int channel):
384 cdef const_char_ptr n
385 n = emotion_object_spu_channel_name_get(self.obj, channel)
386 if n != NULL:
387 return n
388 590
389 def spu_channel_get(self): 591 def spu_channel_get(self):
390 return emotion_object_spu_channel_get(self.obj) 592 return emotion_object_spu_channel_get(self.obj)
391
392 def spu_channel_set(self, int value): 593 def spu_channel_set(self, int value):
393 emotion_object_spu_channel_set(self.obj, value) 594 emotion_object_spu_channel_set(self.obj, value)
394 595
395 def spu_button_count_get(self):
396 return emotion_object_spu_button_count_get(self.obj)
397
398 property spu_button_count: 596 property spu_button_count:
597 """ SPU button count
598
599 :type: int
600 """
399 def __get__(self): 601 def __get__(self):
400 return self.spu_button_count_get() 602 return self.spu_button_count_get()
401 603
402 def spu_button_get(self): 604 def spu_button_count_get(self):
403 return emotion_object_spu_button_get(self.obj) 605 return emotion_object_spu_button_count_get(self.obj)
404 606
405 property spu_button: 607 property spu_button:
406 def __get__(self): 608 """ SPU button
407 return self.spu_button_get()
408 609
409 property spu_channel: 610 :type: int
611 """
410 def __get__(self): 612 def __get__(self):
411 return self.spu_channel_get() 613 return self.spu_button_get()
412 614
413 def __set__(self, int value): 615 def spu_button_get(self):
414 self.spu_channel_set(value) 616 return emotion_object_spu_button_get(self.obj)
415 617
416 def chapter_count(self): 618 def chapter_count(self):
417 return emotion_object_chapter_count(self.obj) 619 """ Return the number of chapters in the stream.
418 620
419 def chapter_name_get(self, int channel): 621 :rtype: int
420 cdef const_char_ptr n 622 """
421 n = emotion_object_chapter_name_get(self.obj, channel) 623 return emotion_object_chapter_count(self.obj)
422 if n != NULL:
423 return n
424 624
425 def chapter_get(self): 625 def chapter_name_get(self, int chapter):
426 return emotion_object_chapter_get(self.obj) 626 """ Get the name of the given chapter.
427 627
428 def chapter_set(self, int value): 628 :param chapter: the chapter number
429 emotion_object_chapter_set(self.obj, value) 629 :type chapter: int
630 :return: the name of the chapter
631 :rtype: str
632 """
633 return _ctouni(emotion_object_chapter_name_get(self.obj, chapter))
430 634
431 property chapter: 635 property chapter:
636 """ The currently selected chapter.
637
638 :type: int
639 """
432 def __get__(self): 640 def __get__(self):
433 return self.chapter_get() 641 return emotion_object_chapter_get(self.obj)
434 642
435 def __set__(self, int value): 643 def __set__(self, int value):
436 self.chapter_set(value) 644 emotion_object_chapter_set(self.obj, value)
437 645
438 def play_speed_get(self): 646 def chapter_get(self):
439 return emotion_object_play_speed_get(self.obj) 647 return emotion_object_chapter_get(self.obj)
648 def chapter_set(self, int value):
649 emotion_object_chapter_set(self.obj, value)
440 650
441 def play_speed_set(self, double value): 651 def eject(self):
442 emotion_object_play_speed_set(self.obj, value) 652 """ Eject the media """
653 emotion_object_eject(self.obj)
443 654
444 property play_speed: 655 property title:
445 def __get__(self): 656 """ The dvd title from this emotion object.
446 return self.play_speed_get()
447 657
448 def __set__(self, double value): 658 .. note:: This function is only useful when playing a DVD.
449 self.play_speed_set(value)
450 659
451 def eject(self): 660 :type: str
452 emotion_object_eject(self.obj) 661 """
662 def __get__(self):
663 return _ctouni(emotion_object_title_get(self.obj))
453 664
454 def title_get(self): 665 def title_get(self):
455 cdef const_char_ptr t 666 return _ctouni(emotion_object_title_get(self.obj))
456 t = emotion_object_title_get(self.obj)
457 if t != NULL:
458 return t
459 667
460 property title: 668 property progress_info:
669 """ How much of the file has been played.
670
671 .. warning:: gstreamer xine backends don't implement this(will return None).
672
673 :type: str
674 """
461 def __get__(self): 675 def __get__(self):
462 return self.title_get() 676 return _ctouni(emotion_object_progress_info_get(self.obj))
463 677
464 def progress_info_get(self): 678 def progress_info_get(self):
465 cdef const_char_ptr s 679 return _ctouni(emotion_object_progress_info_get(self.obj))
466 s = emotion_object_progress_info_get(self.obj)
467 if s != NULL:
468 return s
469 680
470 property progress_info: 681 property progress_status:
682 """ How much of the file has been played.
683
684 The progress in playing the file, the value is in the [0, 1] range.
685
686 .. warning:: gstreamer xine backends don't implement this(will return 0).
687
688 :type: float
689 """
471 def __get__(self): 690 def __get__(self):
472 return self.progress_info_get() 691 return emotion_object_progress_status_get(self.obj)
473 692
474 def progress_status_get(self): 693 def progress_status_get(self):
475 return emotion_object_progress_status_get(self.obj) 694 return emotion_object_progress_status_get(self.obj)
476 695
477 property progress_status: 696 property ref_file:
697 """ ref file
698
699 :type: str
700 """
478 def __get__(self): 701 def __get__(self):
479 return self.progress_status_get() 702 return _ctouni(emotion_object_ref_file_get(self.obj))
480 703
481 def ref_file_get(self): 704 def ref_file_get(self):
482 cdef const_char_ptr s 705 return _ctouni(emotion_object_ref_file_get(self.obj))
483 s = emotion_object_ref_file_get(self.obj)
484 if s != NULL:
485 return s
486 706
487 property ref_file: 707 property ref_num:
708 """ ref number
709
710 :type: int
711 """
488 def __get__(self): 712 def __get__(self):
489 return self.ref_file_get() 713 return emotion_object_ref_num_get(self.obj)
490 714
491 def ref_num_get(self): 715 def ref_num_get(self):
492 return emotion_object_ref_num_get(self.obj) 716 return emotion_object_ref_num_get(self.obj)
493 717
494 property ref_num:
495 def __get__(self):
496 return self.ref_num_get()
497
498 def meta_info_get(self, int meta_id): 718 def meta_info_get(self, int meta_id):
499 cdef const_char_ptr s 719 """ Retrieve meta information from this file being played.
500 s = emotion_object_meta_info_get(self.obj, <Emotion_Meta_Info>meta_id) 720
501 if s != NULL: 721 This function retrieves information about the file loaded. It can retrieve
502 return s 722 the track title, artist name, album name, etc.
723
724 :param meta_id: The type of meta information that will be extracted.
725 :type meta_id: int
726 :return: The info or None
727 :rtype: str
728
729 :see also: meta_info_dict_get().
730 :see also: Emotion_Meta_Info for all the possibilities.
731 """
732 return _ctouni(emotion_object_meta_info_get(self.obj, <Emotion_Meta_Info>meta_id))
503 733
504 def meta_info_dict_get(self): 734 def meta_info_dict_get(self):
735 """ Get a python dictionary with all the know info.
736
737 :return: all the know meta info for the media file
738 :rtype: dict
739 """
505 cdef const_char_ptr info 740 cdef const_char_ptr info
506 ret = dict() 741 ret = dict()
507 lst = (("title", EMOTION_META_INFO_TRACK_TITLE), 742 lst = (("title", EMOTION_META_INFO_TRACK_TITLE),
@@ -523,7 +758,36 @@ cdef class Emotion(evasObject):
523 def __get__(self): 758 def __get__(self):
524 return self.meta_info_dict_get() 759 return self.meta_info_dict_get()
525 760
761 def event_simple_send(self, int event_id):
762 """ Send a named signal to the object.
763
764 :param event_id: the signal to emit, one of EMOTION_EVENT_MENU1,
765 EMOTION_EVENT_MENU2, EMOTION_EVENT_UP, EMOTION_EVENT_1,
766 or any other EMOTION_EVENT_* definition
767 :type event_id: Emotion_Event
768 """
769 emotion_object_event_simple_send(self.obj, <Emotion_Event>event_id)
770
771
526 def callback_add(self, char *event, func, *args, **kargs): 772 def callback_add(self, char *event, func, *args, **kargs):
773 """ Add a new function (**func**) to be called on the specific **event**.
774
775 The expected signature for **func** is::
776
777 func(object, *args, **kwargs)
778
779 .. note:: Any extra params givento the function (both positional
780 and keyword arguments) will be passed back in the
781 callback function.
782
783 :see also: All the on_*_add() shortcut functions
784
785 :param event: the name of the event
786 :type event: str
787 :param func: the function to call
788 :type func: callable
789
790 """
527 e = intern(event) 791 e = intern(event)
528 lst = self._emotion_callbacks.setdefault(e, []) 792 lst = self._emotion_callbacks.setdefault(e, [])
529 if not lst: 793 if not lst:
@@ -532,6 +796,16 @@ cdef class Emotion(evasObject):
532 lst.append((func, args, kargs)) 796 lst.append((func, args, kargs))
533 797
534 def callback_del(self, char *event, func): 798 def callback_del(self, char *event, func):
799 """ Stop the given function **func** to be called on **event**
800
801 :see also: all the on_*_add() shortcut functions
802
803 :param event: the name of the event
804 :type event: str
805 :param func: the function that was previously attached
806 :type func: callable
807
808 """
535 try: 809 try:
536 lst = self._emotion_callbacks[event] 810 lst = self._emotion_callbacks[event]
537 except KeyError, e: 811 except KeyError, e:
@@ -552,75 +826,99 @@ cdef class Emotion(evasObject):
552 evas_object_smart_callback_del(self.obj, event, _emotion_callback) 826 evas_object_smart_callback_del(self.obj, event, _emotion_callback)
553 827
554 def on_frame_decode_add(self, func, *args, **kargs): 828 def on_frame_decode_add(self, func, *args, **kargs):
829 "Same as calling: callback_add('frame_decode', func, ...)"
555 self.callback_add("frame_decode", func, *args, **kargs) 830 self.callback_add("frame_decode", func, *args, **kargs)
556 831
557 def on_frame_decode_del(self, func): 832 def on_frame_decode_del(self, func):
833 "Same as calling: callback_del('frame_decode', func)"
558 self.callback_del("frame_decode", func) 834 self.callback_del("frame_decode", func)
559 835
560 def on_frame_resize_add(self, func, *args, **kargs): 836 def on_frame_resize_add(self, func, *args, **kargs):
837 "Same as calling: callback_add('frame_resize', func, ...)"
561 self.callback_add("frame_resize", func, *args, **kargs) 838 self.callback_add("frame_resize", func, *args, **kargs)
562 839
563 def on_frame_resize_del(self, func): 840 def on_frame_resize_del(self, func):
841 "Same as calling: callback_del('frame_resize', func)"
564 self.callback_del("frame_resize", func) 842 self.callback_del("frame_resize", func)
565 843
566 def on_length_change_add(self, func, *args, **kargs): 844 def on_length_change_add(self, func, *args, **kargs):
845 "Same as calling: callback_add('length_change', func, ...)"
567 self.callback_add("length_change", func, *args, **kargs) 846 self.callback_add("length_change", func, *args, **kargs)
568 847
569 def on_length_change_del(self, func): 848 def on_length_change_del(self, func):
849 "Same as calling: callback_del('length_change', func)"
570 self.callback_del("length_change", func) 850 self.callback_del("length_change", func)
571 851
572 def on_decode_stop_add(self, func, *args, **kargs): 852 def on_decode_stop_add(self, func, *args, **kargs):
853 "Same as calling: callback_add('decode_stop', func, ...)"
573 self.callback_add("decode_stop", func, *args, **kargs) 854 self.callback_add("decode_stop", func, *args, **kargs)
574 855
575 def on_decode_stop_del(self, func): 856 def on_decode_stop_del(self, func):
857 "Same as calling: callback_del('decode_stop', func)"
576 self.callback_del("decode_stop", func) 858 self.callback_del("decode_stop", func)
577 859
578 def on_channels_change_add(self, func, *args, **kargs): 860 def on_channels_change_add(self, func, *args, **kargs):
861 "Same as calling: callback_add('channels_change', func, ...)"
579 self.callback_add("channels_change", func, *args, **kargs) 862 self.callback_add("channels_change", func, *args, **kargs)
580 863
581 def on_channels_change_del(self, func): 864 def on_channels_change_del(self, func):
865 "Same as calling: callback_del('channels_change', func)"
582 self.callback_del("channels_change", func) 866 self.callback_del("channels_change", func)
583 867
584 def on_title_change_add(self, func, *args, **kargs): 868 def on_title_change_add(self, func, *args, **kargs):
869 "Same as calling: callback_add('title_change', func, ...)"
585 self.callback_add("title_change", func, *args, **kargs) 870 self.callback_add("title_change", func, *args, **kargs)
586 871
587 def on_title_change_del(self, func): 872 def on_title_change_del(self, func):
873 "Same as calling: callback_del('title_change', func)"
588 self.callback_del("title_change", func) 874 self.callback_del("title_change", func)
589 875
590 def on_progress_change_add(self, func, *args, **kargs): 876 def on_progress_change_add(self, func, *args, **kargs):
877 "Same as calling: callback_add('progress_change', func, ...)"
591 self.callback_add("progress_change", func, *args, **kargs) 878 self.callback_add("progress_change", func, *args, **kargs)
592 879
593 def on_progress_change_del(self, func): 880 def on_progress_change_del(self, func):
881 "Same as calling: callback_del('progress_change', func)"
594 self.callback_del("progress_change", func) 882 self.callback_del("progress_change", func)
595 883
596 def on_ref_change_add(self, func, *args, **kargs): 884 def on_ref_change_add(self, func, *args, **kargs):
885 "Same as calling: callback_add('ref_change', func, ...)"
597 self.callback_add("ref_change", func, *args, **kargs) 886 self.callback_add("ref_change", func, *args, **kargs)
598 887
599 def on_ref_change_del(self, func): 888 def on_ref_change_del(self, func):
889 "Same as calling: callback_del('ref_change', func)"
600 self.callback_del("ref_change", func) 890 self.callback_del("ref_change", func)
601 891
602 def on_button_num_change_add(self, func, *args, **kargs): 892 def on_button_num_change_add(self, func, *args, **kargs):
893 "Same as calling: callback_add('button_num_change', func, ...)"
603 self.callback_add("button_num_change", func, *args, **kargs) 894 self.callback_add("button_num_change", func, *args, **kargs)
604 895
605 def on_button_num_change_del(self, func): 896 def on_button_num_change_del(self, func):
897 "Same as calling: callback_del('button_num_change', func)"
606 self.callback_del("button_num_change", func) 898 self.callback_del("button_num_change", func)
607 899
608 def on_button_change_add(self, func, *args, **kargs): 900 def on_button_change_add(self, func, *args, **kargs):
901 "Same as calling: callback_add('button_change', func, ...)"
609 self.callback_add("button_change", func, *args, **kargs) 902 self.callback_add("button_change", func, *args, **kargs)
610 903
611 def on_button_change_del(self, func): 904 def on_button_change_del(self, func):
905 "Same as calling: callback_del('button_change', func)"
612 self.callback_del("button_change", func) 906 self.callback_del("button_change", func)
613 907
614 def on_playback_finished_add(self, func, *args, **kargs): 908 def on_playback_finished_add(self, func, *args, **kargs):
909 "Same as calling: callback_add('playback_finished', func, ...)"
615 self.callback_add("playback_finished", func, *args, **kargs) 910 self.callback_add("playback_finished", func, *args, **kargs)
616 911
617 def on_playback_finished_del(self, func): 912 def on_playback_finished_del(self, func):
913 "Same as calling: callback_del('playback_finished', func)"
618 self.callback_del("playback_finished", func) 914 self.callback_del("playback_finished", func)
619 915
620 def on_audio_level_change_add(self, func, *args, **kargs): 916 def on_audio_level_change_add(self, func, *args, **kargs):
917 "Same as calling: callback_add('audio_level_change', func, ...)"
621 self.callback_add("audio_level_change", func, *args, **kargs) 918 self.callback_add("audio_level_change", func, *args, **kargs)
622 919
623 def on_audio_level_change_del(self, func): 920 def on_audio_level_change_del(self, func):
921 "Same as calling: callback_del('audio_level_change', func)"
624 self.callback_del("audio_level_change", func) 922 self.callback_del("audio_level_change", func)
625 923
626 924