Play, set volume and frequency of a sound with phonon
-
Hey guys,
I’m a beginner of this kind of programming language and I’m trying to create a program that plays a sound and sets the volume and the frequency of that sound in pyqt.
I'm trying to use phonon with this code to play a song:@import sys
import PyQt4 QtCore and QtGui modules
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.phonon import Phononfrom mainwindow import MainWindow
if name == 'main':
# create application app = QApplication( sys.argv ) app.setApplicationName( 'Sound project' ) # create widget w = MainWindow() w.setWindowTitle( 'Sound project' ) w.show() # connection QObject.connect( app, SIGNAL( 'lastWindowClosed()' ), app, SLOT( 'quit()' ) ) output = Phonon.AudioOutput(Phonon.MusicCategory) m_media = Phonon.MediaObject() Phonon.createPath(m_media, output) m_media.setCurrentSource(Phonon.MediaSource("C:\Sound_project\Sound.mp3")) m_media.play() # execute application sys.exit( app.exec_() )@
it don't give me errors but I can't hear nothing from my speakers.
could anyone help me??
thanks in advance you your help (and sorry for my english) -
Hi,
Are you really sure that no error are happening ? Have a look at the music player example.
And it's better to use forward slashes for path even on windows.
Last thing, just check that your speakers are on, that the mixer volume is set to something and that the default output is also using your speakers (you might have an active optical output or ear speakers connected etc...)