Shoegaze Player!! It's only a experience

Well!
Today I finish a very small project, I created a audio player with Python, Qt4 and the Gstreamer.
So, look a screenshot:

Yes, I'm using GNOME

It's very simple, you white the directory from the music and click in the button play to play(logic =P)

The source is here:

#!/usr/bin/python
#Writed by Carlos Junior Felix Rodrigues in GPL v 2.0

import sys
from PyQt4 import QtGui, QtCore
import gst

player = gst.Pipeline('player')
playbin = gst.element_factory_make('playbin')
player.add(playbin)

class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(355, 30)
self.setWindowIcon(QtGui.QIcon('images/ico.svg'))
self.setWindowTitle('Shoegaze Player')
self.lineedit = QtGui.QLineEdit(self)
self.lineedit.move(100, 5)
self.lineedit.resize(250, 25)
self.play = QtGui.QAction(QtGui.QIcon('images/play'), 'Play', self)
self.stop = QtGui.QAction(QtGui.QIcon('images/stop'), 'Stop', self)
self.play.setShortcut('Ctrl+P')
QtCore.QObject.connect(self.play, QtCore.SIGNAL("triggered()"), self.on_play_clicked)
QtCore.QObject.connect(self.stop, QtCore.SIGNAL("triggered()"), self.on_stop_clicked)
self.toolbar = self.addToolBar('Play')
self.toolbar.addAction(self.play)
self.toolbar.addAction(self.stop)

def on_play_clicked(self):
player.set_state(gst.STATE_PLAYING)
playbin.set_property('uri','file:///'+ self.lineedit.displayText())

def on_stop_clicked(self):
player.set_state(gst.STATE_NULL)

if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())




Sorry but the buttons I can't post here, I promise to create a package with the icons.

I learned PyQt here:
http://www.zetcode.com/tutorials/pyqt4/
and
here:
http://www.learningpython.com/2008/09/20/an-introduction-to-pyqt/

It's a great advance in my mind. Thank for all the people that help me writing articles!
Remenbering, the player is opensource(GPL 2.0). You can use, edit and redistribute

0 comentários: