Author: remi
Date: 2009-08-31 10:38:01 +0200 (Mon, 31 Aug 2009)
New Revision: 5312

Modified:
   
software_suite_v3/software/plugin/plugin-webradio/trunk/executables/plugin-webradio.py
   software_suite_v3/software/plugin/plugin-webradio/trunk/resources/plugin.xml
Log:
* Added method to clean mplayer instances on Windows.
* Updated version to 0.0.9

Modified: 
software_suite_v3/software/plugin/plugin-webradio/trunk/executables/plugin-webradio.py
===================================================================
--- 
software_suite_v3/software/plugin/plugin-webradio/trunk/executables/plugin-webradio.py
      2009-08-18 15:18:42 UTC (rev 5311)
+++ 
software_suite_v3/software/plugin/plugin-webradio/trunk/executables/plugin-webradio.py
      2009-08-31 08:38:01 UTC (rev 5312)
@@ -55,17 +55,21 @@
 
 2009/06/29 - version 0.0.8:
     - Added support of webradio address
+    
+2009/08/31 - version 0.0.9:
+    - Added method to clean mplayer instances at plugin exit (Windows)
 """
 
 __author__  = "Eric Lescaudron AKA Gwadavel"
 __appname__ = "tux web radio"
-__version__ = "0.0.8"
-__date__    = "2009/06/05"
+__version__ = "0.0.9"
+__date__    = "2009/08/31"
 __license__ = "GPL"
 
 import os
 import time
 import sys
+import threading
 
 sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL'])
 
@@ -164,10 +168,46 @@
         self.__speakRadioName(radioName)
         self.__player.start(radioUrl, True)
 
+    def __killMplayerInstances(self):
+        """Kill mplayer instances.
+        """
+        if os.name == "nt":
+            import pythoncom
+            import win32api
+            from win32com.client import GetObject
+            pythoncom.CoInitialize()
+            WMI = GetObject('winmgmts:')
+            processes = WMI.InstancesOf('Win32_Process')
+            pidToKill = []
+            for process in processes:
+                name = process.Properties_('Name').Value
+                cmdLine = process.Properties_('CommandLine').Value
+                pid = process.Properties_('ProcessId').Value
+                if name.lower() == "mplayer.exe":
+                    if (cmdLine.lower().find('smart-server') != -1) and \
+                        (cmdLine.lower().find('util') != -1):
+                        pidToKill.append(pid)
+            for pid in pidToKill:
+                try:
+                    handle = win32api.OpenProcess(1, False, pid)
+                    win32api.TerminateProcess(handle, -1)
+                    win32api.CloseHandle(handle)
+                except:
+                    pass
+            pythoncom.CoUninitialize()
+
+    def cleanUp(self):
+        """Clean up mplayer.
+        """
+        t = threading.Thread(target = self.__killMplayerInstances)
+        t.start()
+        time.sleep(0.25)
+
     def onPluginStop(self):
         """Event on plugin stop.
         """
         self.__player.stop()
+        self.cleanUp()
 
     def onPluginEvent(self, eventName, eventValues):
         """Callback on plugin event.

Modified: 
software_suite_v3/software/plugin/plugin-webradio/trunk/resources/plugin.xml
===================================================================
--- 
software_suite_v3/software/plugin/plugin-webradio/trunk/resources/plugin.xml    
    2009-08-18 15:18:42 UTC (rev 5311)
+++ 
software_suite_v3/software/plugin/plugin-webradio/trunk/resources/plugin.xml    
    2009-08-31 08:38:01 UTC (rev 5312)
@@ -8,7 +8,7 @@
         <ttsName>Plugin webradio.</ttsName>
                <description>This plugin controls the webradios.</description>
                <author>Gwadavel and Kysoh</author>
-               <version>0.0.8</version>
+               <version>0.0.9</version>
                <iconFile>resources/icon.png</iconFile>
                <uuid>8349ed52-572d-4c3f-a7b8-05c2a8aec2c6</uuid>
         <platform>all</platform>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to