changeset 674:539de47b68cc

asco: fix the EOS catcher instead of the broken duration-.2 hack Ignore-this: 76db6d1c0eea79e6db88f95984059105
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 20 Jun 2011 20:18:34 +0000
parents 865532790e62
children c4162943fedc
files bin/ascoltami2 light9/ascoltami/player.py
diffstat 2 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/bin/ascoltami2	Mon Jun 20 20:18:06 2011 +0000
+++ b/bin/ascoltami2	Mon Jun 20 20:18:34 2011 +0000
@@ -33,6 +33,8 @@
         self.player.pause()
         self.player.seek(0)
 
+        # stop here for now- no go-button behavior
+        return
         try:
             nextSong = self.playlist.nextSong(song)
         except NoSuchSong: # we're at the end of the playlist
--- a/light9/ascoltami/player.py	Mon Jun 20 20:18:06 2011 +0000
+++ b/light9/ascoltami/player.py	Mon Jun 20 20:18:34 2011 +0000
@@ -32,10 +32,14 @@
         bus.add_signal_watch()
 
         def on_any(bus, msg):
-            print bus, msg
-        #bus.connect('message', on_any)
+            print bus, msg, msg.type
+            if msg.type == gst.MESSAGE_EOS:
+                if self.onEOS is not None:
+                    self.onEOS(self.getSong())
+        bus.connect('message', on_any)
 
         def onStreamStatus(bus, message):
+            print "streamstatus", bus, message
             (statusType, _elem) = message.parse_stream_status()
             if statusType == gst.STREAM_STATUS_TYPE_ENTER:
                 self.setupAutostop()
@@ -52,12 +56,14 @@
             if self.lastWatchTime < self.autoStopTime < t:
                 log.info("autostop")
                 self.pause()
-            if not self.onEOS:
-                if self.isPlaying() and t >= self.duration() - .2:
-                    # i don't expect to hit dur exactly with this
-                    # polling. What would be better would be to watch for
-                    # the EOS signal and react to that
-                    self.onEOS(self.getSong())
+
+                # new EOS logic above should be better
+            ## if not self.onEOS:
+            ##     if self.isPlaying() and t >= self.duration() - .2:
+            ##         # i don't expect to hit dur exactly with this
+            ##         # polling. What would be better would be to watch for
+            ##         # the EOS signal and react to that
+            ##         self.onEOS(self.getSong())
 
             self.lastWatchTime = t
         except: