def play_phonon(self): self.nslc_ids, data = self.prepare_data() tmpfile = tempfile.mkstemp(dir=self._tmpdir, suffix='.wav')[1] #tmpfile = '/tmp/test.wav' self.export_wav(data=data, fn=tmpfile) output = Phonon.AudioOutput(parent=self._panel_parent) output.setVolume(self.volume/100) Phonon.createPath(self.m_media, output) self.m_media.setCurrentSource(Phonon.MediaSource(tmpfile)) self.marker_thread.media = self.m_media self.marker_thread.speed_up = int(num.round(self.speed_up)) self.m_media.stateChanged.connect(self.marker_thread.handle_states) self.m_media.play()
def setup(self): self.set_name('Play/Save Audio') self.add_parameter(Param('Fast Forward/Rewind', 'speed_up', 10., -20., 30.)) self.add_parameter(Choice('fps', 'fps_choice', '16000', ('44100', '32000', '18000', '16000', '9000', '4000', 'keep original'))) self.add_parameter(Param('Highpass [Hz]', 'corner_highpass', 0.001, 0.001, 100., low_is_none=True)) self.add_parameter(Param('Lowpass [Hz]', 'corner_lowpass', 100., 0.001, 100., high_is_none=True)) self.add_parameter(Param('Fader [percentage]', 'tfade', 5, 0., 50.)) self.add_parameter(Param('Volume', 'volume', 60., 0., 100.)) self.add_parameter(Switch('Follow', 'follow', False)) self.add_trigger('Pause/Play', self.pause_play) self.add_trigger('Stop', self.stop_play) self.add_trigger('Apply Main Control Filters', self.set_from_main) self.add_trigger('Export .wav file', self.export_wav) self.add_trigger('Load .wav file', self.load_data) self.set_live_update(False) self._tmpdir = self.tempdir() self.output = None self.marker_thread = None if not no_phonon: self.m_media = Phonon.MediaObject(self._panel_parent) self.no_phonon_warn = 'Install pyqt4 phonon!\nCan only export wav files.\nCheckout this snuffling\'s help.' self.added_traces = []
def __init__(self, url, parent = None): self.url = url QtGui.QWidget.__init__(self, parent) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.setTickInterval(100) self.player.tick.connect(self.tock) self.play_pause = QtGui.QPushButton(self) #self.play_pause.setMinimumSize(QtCore.QSize(20,20)) #self.play_pause.setMaximumSize(QtCore.QSize(50,25)) #self.play_pause.setIcon(QtGui.QIcon(':/icons/player_play.svg')) self.play_pause.setText("Play") self.play_pause.clicked.connect(self.playClicked) self.player.stateChanged.connect(self.stateChanged) self.slider = Phonon.SeekSlider(self.player , self) self.status = QtGui.QLabel(self) self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.download = QtGui.QPushButton("Download", self) self.download.clicked.connect(self.fetch) layout = QtGui.QHBoxLayout(self) layout.addWidget(self.play_pause) layout.addWidget(self.slider) layout.addWidget(self.status) layout.addWidget(self.download) self.setUrl("")
def _play(self): source = Phonon.MediaSource(self._path) self._player.setCurrentSource(source) self._player.play()
def __init__(self, parent, temp_dir): self._player = Phonon.createPlayer(Phonon.NoCategory) self._player.finished.connect(self._onFinished) self._alive = set()
import sys from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.phonon import Phonon app = QtWidgets.QApplication(sys.argv) vp = Phonon.VideoPlayer() vp.show() media = Phonon.MediaSource('drop.avi') vp.load(media) vp.play() sys.exit(app.exec_())