[Player-cvs] mid/import realplayer-import,1.4,1.5
zhuao at helixcommunity.org zhuao at helixcommunity.orgUpdate of /cvsroot/player/mid/import
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv20137/import
Modified Files:
realplayer-import
Log Message:
Synopsis:
1. handle progress bar exception
2. skip DivX content during media import
3. add dbus-server exception handler
Overview:
1. handle progress bar exception
https://bugs.helixcommunity.org/show_bug.cgi?id=8360
when you plug a usb disk for a second time, there is some exception for media import.
"./realplayer-import:68: PangoWarning: pango_layout_get_line_count: assertion `layout != NULL' failed"
the reason is: since all media content has copied to device at the first time,
at the second time media import will update the progress bar in a high frequency,
lead to some exception from gdk.
I move the action of update progressbar to a real copy (new files found),
and also the progress bar update action is in "try: ...exception:..." to avoid this.
2. skip DivX content during media import
https://bugs.helixcommunity.org/show_bug.cgi?id=8281
analysis the mime type of avi content, if DivX streams, skip them.
3. add dbus-server exception handler
add some error handler for function call(GetMediaInfo()) to dbus-server.
Files Added:
No file added
Files Modified:
player/mid/import/realplayer-import
Synopsis:
Before drag (or click) progress bar call StartSeeking();
After drag (or click) progress bar call StopSeeking().
Overview:
fix bug #8258:
Click on the progress bar to change the play position is not acute
https://bugs.helixcommunity.org/show_bug.cgi?id=8258
we try to use StartSeeking()-->multi-SetPosition()-->StopSeeking() to replace
Pause()-->multi-SetPosition()-->Play() for seeking (drag the scroll bar or click
on the scroll bar).
Index: realplayer-import
===================================================================
RCS file: /cvsroot/player/mid/import/realplayer-import,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- realplayer-import 3 Jun 2008 05:54:43 -0000 1.4
+++ realplayer-import 5 Jun 2008 02:34:01 -0000 1.5
@@ -193,28 +193,62 @@
def stop(self):
self.__stop_event.set()
+
+ def __connect_media_service(self):
+ self.__dbus_name = "org.helixcommunity.HelixDbusServer"
+ self.__dbus_path = "/org/helixcommunity/HelixDbusServer/Player"
+ self.__bus = dbus.SessionBus()
+ self.__media_service = self.__bus.get_object(self.__dbus_name, self.__dbus_path)
+ session = self.__bus.get_object("org.freedesktop.DBus","/org/freedesktop/DBus")
+ self.__pid = session.GetConnectionUnixProcessID(self.__dbus_name)
+
+ def __handle_media_service_exception(self):
+ try:
+ os.kill(self.__pid, signal.SIGKILL)
+ except:
+ pass
+ self.__connect_media_serice()
def run(self):
- dbus_name = 'org.helixcommunity.HelixDbusServer'
- dbus_path = '/org/helixcommunity/HelixDbusServer/Player'
- m_dbus = dbus.SessionBus()
- media_service = m_dbus.get_object(dbus_name, dbus_path)
- media_files = []
- photo_thumbnails = []
+ self.__connect_media_service()
+ media_files = []
+ photo_thumbnails = []
for root, dirs, files in os.walk(self.__mount_point):
for f in files:
name, tmp = os.path.splitext(f)
if name == "":
+ # ignore hidden files
pass
else:
ext = tmp.replace('.', '').lower()
if ext == "rm" or ext == "rmvb" or ext == "ogg":
+ # for ogg or rm stream, try to detect whether it is audio only or not.
m_file = os.path.join(root, f)
- mime_type = media_service.GetMediaInfo(m_file)
- if mime_type.find("video") != -1:
+ try:
+ mime_type = self.__media_service.GetMediaInfo(m_file)
+ if mime_type.find("video") != -1:
+ media_files.append([m_file, os.path.join(self.__video_path, f)])
+ else:
+ media_files.append([m_file, os.path.join(self.__audio_path, f)])
+ except:
+ try:
+ self.__handle_media_service_exception()
+ except:
+ pass
+ # exception occurs, we take it as video for default.
media_files.append([m_file, os.path.join(self.__video_path, f)])
- else:
- media_files.append([m_file, os.path.join(self.__audio_path, f)])
+ elif ext == "avi":
+ m_file = os.path.join(root, f)
+ try:
+ mime_type = self.__media_service.GetMediaInfo(m_file)
+ if mime_type.find("X-HX-DIVX") == -1: # not a DivX stream
+ media_files.append([m_file, os.path.join(self.__video_path, f)])
+ except:
+ try:
+ self.__handle_media_service_exception()
+ except:
+ pass
+ # exception occurs, we discard this stream
else:
if ext in constant.MediaType['video']:
media_files.append([os.path.join(root, f),
@@ -231,10 +265,10 @@
for entry in media_files:
path, name = os.path.split(entry[0])
count = count + 1
- self.__pbar.set_fraction(float(count)/len(media_files))
- self.__lbcopying.set_text('%s: %s ' % (_("File"), name))
if not os.path.isfile(entry[1]):
try:
+ self.__pbar.set_fraction(float(count)/len(media_files))
+ self.__lbcopying.set_text('%s: %s ' % (_("File"), name))
shutil.copy2(entry[0], entry[1])
except:
pass