Changeset - 539de47b68cc
[Not reviewed]
default
0 2 0
Drew Perttula - 14 years ago 2011-06-20 20:18:34
drewp@bigasterisk.com
asco: fix the EOS catcher instead of the broken duration-.2 hack
Ignore-this: 76db6d1c0eea79e6db88f95984059105
2 files changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami2
Show inline comments
 
@@ -30,12 +30,14 @@ class App:
 
        mainloop.run()
 

	
 
    def onEOS(self, song):
 
        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
 
            return
 

	
 
        self.player.setSong(nextSong, play=False)
light9/ascoltami/player.py
Show inline comments
 
@@ -29,16 +29,20 @@ class Player(object):
 
        gobject.timeout_add(50, self.watchTime)
 

	
 
        bus = self.pipeline.get_bus()
 
        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()
 
        bus.connect('message::stream-status', onStreamStatus)
 

	
 
    def watchTime(self):
 
@@ -49,18 +53,20 @@ class Player(object):
 
                return True
 
            log.debug("watch %s < %s < %s",
 
                      self.lastWatchTime, self.autoStopTime, t)
 
            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:
 
            traceback.print_exc()
 
        return True
 

	
0 comments (0 inline, 0 general)