#!/usr/bin/env python import sys from qt import * import gst import pygst class Player(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) self.setCaption("SimPlay - The Simple Music Player") self.setGeometry(0,0,211,262) self.playPause = QPushButton("&Play/Pause", self) self.playPause.setGeometry(0,0,105,24) self.quit = QPushButton("&Quit", self) self.quit.setGeometry(105,0,105,24) self.paused = True self.playListWidget = QListBox(self, "playListWidget") self.playListWidget.setGeometry(QRect(0,51,210,210)) self.fileToPlay = QLineEdit(self) self.fileToPlay.setGeometry(0,25,210,24) self.filePlayer = gst.element_factory_make("playbin", "self.filePlayer") #CLick actions, connects etc.: self.connect(self.playPause, SIGNAL("clicked()"), self.doPlayPause) self.connect(self.quit, SIGNAL("clicked()"), self.close) def doPlayPause(self): technicalUri = self.fileToPlay.text() if self.paused: self.paused = False newUri = "file://" + self.fileToPlay.text() #if newUri != uri: # self.filePlayer.set_state(gst.STATE_STOPPED) # self.filePlayer.set_property('uri', newUri) # self.filePlayer.set_state(gst.STATE_PLAYING) #else: print newUri self.filePlayer.set_property('uri', newUri) self.filePlayer.set_state(gst.STATE_PLAYING) elif not self.paused: uri = "file://" + self.fileToPlay.text() self.paused = True print "Now Pausing" self.filePlayer.set_state(gst.STATE_PAUSED) if __name__ == "__main__": app = QApplication(sys.argv) app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT('quit()')) player = Player() player.show() player.playPause.show() app.setMainWidget(player) app.exec_loop()