Thanks, pushed in sugar-0.94 branch.<div><br></div><div>Gonzalo<br><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 2:28 PM, Manuel Kaufmann <span dir="ltr"><<a href="mailto:humitos@gmail.com" target="_blank">humitos@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Stop the player when the user is reproducing a video and switch to<br>
another activity.<br>
<br>
Signed-off-by: Manuel Kaufmann <<a href="mailto:humitos@gmail.com">humitos@gmail.com</a>><br>
---<br>
jukeboxactivity.py | 23 ++++++++++++++++++++---<br>
1 file changed, 20 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/jukeboxactivity.py b/jukeboxactivity.py<br>
index e900263..cb116a8 100644<br>
--- a/jukeboxactivity.py<br>
+++ b/jukeboxactivity.py<br>
@@ -131,6 +131,11 @@ class JukeboxActivity(activity.Activity):<br>
toolbar_box.show_all()<br>
self.connect("key_press_event", self._key_press_event_cb)<br>
<br>
+ # We want to be notified when the activity gets the focus or<br>
+ # loses it. When it is not active, we don't need to keep<br>
+ # reproducing the video<br>
+ self.connect("notify::active", self._notify_active_cb)<br>
+<br>
if handle.uri:<br>
pass<br>
elif self._shared_activity:<br>
@@ -155,7 +160,6 @@ class JukeboxActivity(activity.Activity):<br>
self.playflag = False<br>
self.tags = {}<br>
self.only_audio = False<br>
- self.got_stream_info = False<br>
<br>
self.tag_reader = TagReader()<br>
self.tag_reader.connect('get-tags', self.__get_tags_cb)<br>
@@ -187,6 +191,20 @@ class JukeboxActivity(activity.Activity):<br>
self.uri = handle.uri<br>
gobject.idle_add(self._start, self.uri, handle.title)<br>
<br>
+ def _notify_active_cb(self, widget, event):<br>
+ """Sugar notify us that the activity is becoming active or<br>
+ inactive.<br>
+<br>
+ When we are inactive, we stop the player if it is reproducing<br>
+ a video.<br>
+ """<br>
+<br>
+ if self.player is not None and not self.only_audio:<br>
+ if not self.player.is_playing() and self.props.active:<br>
+ self.player.play()<br>
+ if self.player.is_playing() and not self.props.active:<br>
+ self.player.pause()<br>
+<br>
def _switch_canvas(self, show_video):<br>
"""Show or hide the video visualization in the canvas.<br>
<br>
@@ -333,7 +351,7 @@ class JukeboxActivity(activity.Activity):<br>
self.tags[gst.TAG_ARTIST], album)<br>
<br>
def _player_stream_info_cb(self, widget, stream_info):<br>
- if not len(stream_info) or self.got_stream_info:<br>
+ if not len(stream_info):<br>
return<br>
<br>
GST_STREAM_TYPE_UNKNOWN = 0<br>
@@ -346,7 +364,6 @@ class JukeboxActivity(activity.Activity):<br>
if item.props.type == GST_STREAM_TYPE_VIDEO:<br>
only_audio = False<br>
self.only_audio = only_audio<br>
- self.got_stream_info = True<br>
self._update_overlay()<br>
<br>
def _joined_cb(self, activity):<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.4<br>
<br>
</font></span></blockquote></div><br></div>