Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2013-01-28 20:05:36 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-01-29 13:41:52 (GMT)
commit57461441c9fca6adfb9d08e9f1b8cc8a0d2fed49 (patch)
tree1da18c8b206e56e18024dba0fd4fb3914c7f69cc
parentf2c441717877db34d36cb7925afeacb1e4d03d50 (diff)
Check availability of stream
It's possible to have some streams in the playlist that are not available at the moment the user double-clicks the row or presses the Play button, for example because they are in a Pen Drive. So, this patch checks for the availability of the stream before start playing it and avoiding gstreamer to fail. Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
-rw-r--r--controls.py20
-rw-r--r--playlist.py9
2 files changed, 17 insertions, 12 deletions
diff --git a/controls.py b/controls.py
index 6d50946..d2484c9 100644
--- a/controls.py
+++ b/controls.py
@@ -221,14 +221,18 @@ class Controls(GObject.GObject):
if self.activity.player.player.props.current_uri is None:
# There is no stream selected to be played
# yet. Select the first one
- path = self.activity.playlist_widget._items[0]['path']
- self.activity.playlist_widget._current_playing = 0
- self.activity.player.set_uri(path)
-
- self.activity.player.play()
- self.activity._switch_canvas(True)
- self._scale_update_id = GObject.timeout_add(
- self.SCALE_UPDATE_INTERVAL, self.__update_scale_cb)
+ available = self.activity.playlist_widget.\
+ _items[0]['available']
+ if available:
+ path = self.activity.playlist_widget._items[0]['path']
+ self.activity.playlist_widget.emit(
+ 'play-index', 0, path)
+ self.activity.playlist_widget._current_playing = 0
+ else:
+ self.activity.player.play()
+ self.activity._switch_canvas(True)
+ self._scale_update_id = GObject.timeout_add(
+ self.SCALE_UPDATE_INTERVAL, self.__update_scale_cb)
def set_button_play(self):
self.button.set_icon_widget(self.play_image)
diff --git a/playlist.py b/playlist.py
index fab0ea9..f04d1be 100644
--- a/playlist.py
+++ b/playlist.py
@@ -89,10 +89,11 @@ class PlayList(Gtk.ScrolledWindow):
index = model.get_value(treeiter, COLUMNS['index'])
# TODO: put the path inside the ListStore
path = self._items[index]['path']
- # TODO: check if the stream is available before emitting the signal
- self._current_playing = index
- self.set_cursor(index)
- self.emit('play-index', index, path)
+ available = self._items[index]['available']
+ if available:
+ self._current_playing = index
+ self.set_cursor(index)
+ self.emit('play-index', index, path)
def _set_number(self, column, cell, model, it, data):
idx = model.get_value(it, COLUMNS['index'])