Hi 
I have a play-method in my own stream-player and it works:

    def node_clicked(self, widget, item):
        def play_uri(self, station):
            # We already know the real URL of the playable audio stream, no
            # need to query the resource manager
            # get player and start playing
            player = 
self.frontend.retrieve_controllers('/poblesec/music_player')[0]
            player.player.play_model(station)
            main = self.frontend.retrieve_controllers('/poblesec')[0]
            main.show_music_player()
            self.stop_loading_animation()

        pdb.set_trace()
        if isinstance(item, Action):
            item.run()
        elif isinstance(item, PlayableModel):
            play_uri(self, item)

It works fine but if there are problems with the stream it will hang for a 
while, so I thought I could use a deferred, like:

    def node_clicked(self, widget, item):

        def play_uri(self, station):
            # We already know the real URL of the playable audio stream, no
            # need to query the resource manager
            # get player and start playing
            player = 
self.frontend.retrieve_controllers('/poblesec/music_player')[0]
            player.player.play_model(station)

            main = self.frontend.retrieve_controllers('/poblesec')[0]
            main.show_music_player()
            self.stop_loading_animation()

        pdb.set_trace()
        if isinstance(item, Action):
            item.run()
        elif isinstance(item, PlayableModel):
            dfr = defer.Deferred().addCallback(play_uri)
            return dfr(self, item)

My problem is that I am not sure:
1) Do I create the deferred in the right manner?
2) How does the binding of the parameters happen?
3) Do I need to activate the deferred my self or will this happen by magic by 
it self?

As
far as I can read the deferred can be compared to the .NET asynchronous
delegates or boost::thread. Boost::thread is much simpler but they
share the problem regarding binding variables.

Please help me fix the code!

Best Regards,
Kristian
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Reply via email to