Author: jerome
Date: 2009-03-11 14:05:42 +0100 (Wed, 11 Mar 2009)
New Revision: 3953

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-WMP/trunk/tuxdroid-gadget-WMP/src/com/kysoh/tuxdroid/MediaPlayerThread.java
Log:
* Users can now take the control when wmp is still started, but configuration 
is not applied.

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-WMP/trunk/tuxdroid-gadget-WMP/src/com/kysoh/tuxdroid/MediaPlayerThread.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-WMP/trunk/tuxdroid-gadget-WMP/src/com/kysoh/tuxdroid/MediaPlayerThread.java
      2009-03-11 12:59:55 UTC (rev 3952)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-WMP/trunk/tuxdroid-gadget-WMP/src/com/kysoh/tuxdroid/MediaPlayerThread.java
      2009-03-11 13:05:42 UTC (rev 3953)
@@ -36,6 +36,7 @@
        
        private Configuration configuration;
        private boolean startPlaylist;
+       private static Object mutex = new Object();
        private final Collection<WMPThreadListener> WMPThreadListeners = new 
ArrayList<WMPThreadListener>();
        
        /**
@@ -83,7 +84,7 @@
                        return;
                }
                
-               if (openfile)
+               if (openfile && (!MediaPlayerThread.isWMPStarted()))
                {
                        String[] files = this.configuration.getMediaPath();
                        for(String filename : files)
@@ -177,31 +178,34 @@
           */
          public static boolean isWMPStarted()
          {
-               String cmd = "tasklist /FI \"IMAGENAME eq wmplayer.exe\"";
-               //Total check is under one minute.
-               Process wmpRunning;
-               try 
-               {
-                       wmpRunning = Runtime.getRuntime().exec(cmd);
-                       StreamReader reader = new 
StreamReader(wmpRunning.getInputStream());
-                       reader.start();
-                       wmpRunning.waitFor();
-                       reader.join();
-                       String result = reader.getResult().trim();
-                       if(result.contains("wmplayer.exe"))
+                 synchronized(mutex)
+                 {
+                       String cmd = "tasklist /FI \"IMAGENAME eq 
wmplayer.exe\"";
+                       //Total check is under one minute.
+                       Process wmpRunning;
+                       try 
                        {
-                               return true;
+                               wmpRunning = Runtime.getRuntime().exec(cmd);
+                               StreamReader reader = new 
StreamReader(wmpRunning.getInputStream());
+                               reader.start();
+                               wmpRunning.waitFor();
+                               reader.join();
+                               String result = reader.getResult().trim();
+                               if(result.contains("wmplayer.exe"))
+                               {
+                                       return true;
+                               }
+                       } 
+                       catch (IOException e) 
+                       {
+                               ;
+                       } 
+                       catch (InterruptedException e) 
+                       {
+                               ;
                        }
-               } 
-               catch (IOException e) 
-               {
-                       ;
-               } 
-               catch (InterruptedException e) 
-               {
-                       ;
-               }
-               return false;
+                       return false;
+                 }
          }
          
          


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to