Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2012-08-22 00:15:38 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2012-08-22 00:15:38 (GMT)
commit42adf9fac5777955379574f338ea76d52f68fa0e (patch)
treef604f5172a070ce278af03f331ee121a88307bfd
parent4df20ac581b22502471c1887cbdb992a7ead1008 (diff)
parentb35dfa88870665c0c77cd3c274592c79720573c1 (diff)
Merge branch 'master' of git.sugarlabs.org:jukebox/mainline
-rw-r--r--activity/activity.info2
-rw-r--r--jukeboxactivity.py42
2 files changed, 35 insertions, 9 deletions
diff --git a/activity/activity.info b/activity/activity.info
index 8703a21..7cef463 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -6,5 +6,5 @@ icon = activity-jukebox
exec = sugar-activity jukeboxactivity.JukeboxActivity
show_launcher = yes
activity_version = 27
-mime_types = video/x-theora;audio/x-vorbis;audio/x-flac;audio/x-speex;application/x-ogm-video;application/x-ogm-audio;video/x-mng;audio/x-aiff;audio/x-wav;audio/x-m4a;video/mpeg4;video/mpeg-stream;video/mpeg;application/ogg;video/mpegts;video/mpeg2;video/mpeg1;audio/mpeg;audio/x-ac3;video/x-cdxa;audio/x-au;audio/mpegurl;audio/x-mpegurl;audio/x-vorbis+ogg;audio/x-scpls;audio/ogg;video/ogg;audio/x-flac+ogg;audio/x-speex+ogg;video/x-theora+ogg;video/x-ogm+ogg;video/x-flv
+mime_types = video/x-theora;audio/x-vorbis;audio/x-flac;audio/x-speex;application/x-ogm-video;application/x-ogm-audio;video/x-mng;audio/x-aiff;audio/x-wav;audio/x-m4a;video/mpeg4;video/mpeg-stream;video/mpeg;application/ogg;video/mpegts;video/mpeg2;video/mpeg1;audio/mpeg;audio/x-ac3;video/x-cdxa;audio/x-au;audio/mpegurl;audio/x-mpegurl;audio/x-vorbis+ogg;audio/x-scpls;audio/ogg;video/ogg;audio/x-flac+ogg;audio/x-speex+ogg;video/x-theora+ogg;video/x-ogm+ogg;video/x-flv;video/mp4;video/x-matroska;video/x-msvideo;
diff --git a/jukeboxactivity.py b/jukeboxactivity.py
index 7062fc3..a84f9af 100644
--- a/jukeboxactivity.py
+++ b/jukeboxactivity.py
@@ -36,6 +36,7 @@ from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.graphics.toolbarbox import ToolbarButton
from sugar3.activity.widgets import StopButton
from sugar3.activity.widgets import ActivityToolbarButton
+from sugar3.graphics.alert import ErrorAlert
import gi
gi.require_version('Gtk', '3.0')
@@ -250,19 +251,39 @@ class JukeboxActivity(activity.Activity):
self.player.connect("tag", self._player_new_tag_cb)
self.player.connect("stream-info", self._player_stream_info_cb)
url = self.playlist[self.currentplaying]['url']
+ error = None
if url.startswith('journal://'):
- jobject = datastore.get(url[len("journal://"):])
- url = 'file://' + jobject.file_path
- self.player.set_uri(url)
-
- self.play_toggled()
+ try:
+ jobject = datastore.get(url[len("journal://"):])
+ url = 'file://' + jobject.file_path
+ except:
+ path = url[len("journal://"):]
+ error = _('The file %s was not found') % path
self.check_if_next_prev()
+
+ if error is None:
+ self.player.set_uri(url)
+ self.play_toggled()
+ else:
+ self.control.set_disabled()
+ self._show_error_alert(error)
+
self.playlist_widget.set_cursor(self.currentplaying)
def _player_eos_cb(self, widget):
self.songchange('next')
+ def _show_error_alert(self, title):
+ alert = ErrorAlert()
+ alert.props.title = title
+ self.add_alert(alert)
+ alert.connect('response', self._alert_cancel_cb)
+ alert.show()
+
+ def _alert_cancel_cb(self, alert, response_id):
+ self.remove_alert(alert)
+
def _player_error_cb(self, widget, message, detail):
self.player.stop()
self.player.set_uri(None)
@@ -458,6 +479,7 @@ class JukeboxActivity(activity.Activity):
self.playlist.append({'url': uri, 'title': title})
if uri.endswith(title) or title is None or title == '' or \
object_id is not None:
+ error = False
logging.error('Try get a better title reading tags')
# TODO: unify this code....
url = self.playlist[len(self.playlist) - 1]['url']
@@ -465,10 +487,14 @@ class JukeboxActivity(activity.Activity):
url = url[len("journal://"):]
url = 'file://' + url
elif url.startswith('journal://'):
- jobject = datastore.get(url[len("journal://"):])
- url = 'file://' + jobject.file_path
+ try:
+ jobject = datastore.get(url[len("journal://"):])
+ url = 'file://' + jobject.file_path
+ except:
+ error = True
# jobject.destroy() ??
- self.tag_reader.set_file(url, len(self.playlist) - 1)
+ if not error:
+ self.tag_reader.set_file(url, len(self.playlist) - 1)
if not self.player:
# lazy init the player so that videowidget is realized