Hi all, sorry for the vague title but I couldn't think of a better one.
This is what I'm currently attempting: Take the Radio Tray source and strip it of references to the graphical parts (Systray.py and some GTK references). Then build a curses interface and connect it to the parts responsible for audio playback and state change events. I have succeeded in reducing the code but when I try to make a start with the curses part there is a problem. Curses seems to halt execution of the audio player.
The source of Radio Tray can be found here: https://bitbucket.org/carlmig/radio-tray/src I use these files largely unmodified, the most modifications I have made to RadioTray.py
The original code initializes the state mediator, the audioplayer and then invokes systray.run() which contains the following GTK-code:
Code:
gtk.gdk.threads_init()
gtk.main()
I replaced that with a call to my own function
Right now I have outcommented the curses part as there is a problem with that:
Code:
def startCurses(self):
#self.screen = curses.initscr()
#self.screen.erase()
s = ""
while s != "quit":
s = raw_input("> ")
#s = self.screen.getstr(2,1)
if s == "play":
self.mediator.playUrl("http://somafm.com/poptron.pls")
#curses.endwin()
def updateSong(self, data):
#self.screen.addstr(1,1,"title: %s" % data['title'])
print "title: %s" % data['title']
def updateState(self, data):
#self.screen.addstr(1,1,"state: %s" % data['state'])
print "state: %s" % data['state']
In this form the code works. when typing 'play' the station from the fixed url is played. the updateState() and updateSong() methods are neatly called when there is new information. Which surprises me a bit as raw_input() is a blocking call just like curses' getstr() method. When I type play through the curses getstr method only the first "connecting" event is displayed then execution of the audio part seems to halt. This is confirmed by the log file where no new lines appears when normally the gstreamer part starts firing events on state changes of the radio stream.
What I going on here? what makes curses different from the python code without curses?
I can also understand this post is way too vague and I can supply more code if necessary.
Bookmarks