I’ve been searching for a while and haven’t come up with any results yet. I’m trying to do something that I imagine should be fairly simple, but have yet to see a potential solution. My eventual goal is to be able to incorporate a video player into a Maya PyQt interface. I’m new to PyQt, and from what I’ve gathered the way to approach something like this is using the Phonon module.
To start with, I’ve been trying to get an interface to play a simple song, since examples of simple audio players using this module seem to abound. Everything seems to work and the window launches just fine, but I’m getting no sound. I was curious whether anyone else has attempted to get a video or music to play in Maya. If the Phonon module is not the proper approach, I’d appreciate any advice on the subject.
As I said, I’m very new to PyQt, and it wouldn’t surprise me that I have made a very simple error.
My code is as follows:
from PyQt4 import QtCore from PyQt4 import QtGui from PyQt4.phonon import Phonon import sip import maya.OpenMayaUI as omu def maya_main_window(): ptr = omu.MQtUtil.mainWindow() return sip.wrapinstance(long(ptr), QtCore.QObject) class My_Player(QtGui.QMainWindow): def __init__(self, parent = maya_main_window()): QtGui.QMainWindow.__init__(self, parent) self.setWindowTitle("My Player") self.playsong() def playsong(self): m_media = Phonon.MediaObject() output = Phonon.AudioOutput(Phonon.MusicCategory) Phonon.createPath(m_media, output) m_media.setCurrentSource(Phonon.MediaSource("C:/Users/Ben/Documents/media.mp3")) m_media.play() win = My_Player() try: win.close() except: pass win.show()