def __init__(self): QtGui.QMainWindow.__init__(self) self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) self.mediaObject = Phonon.MediaObject(self) self.metaInformationResolver = Phonon.MediaObject(self) self.mediaObject.setTickInterval(1000) self.connect(self.mediaObject, QtCore.SIGNAL('tick(qint64)'), self.tick) self.connect( self.mediaObject, QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'), self.stateChanged) self.connect( self.metaInformationResolver, QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'), self.metaStateChanged) self.connect( self.mediaObject, QtCore.SIGNAL('currentSourceChanged(Phonon::MediaSource)'), self.sourceChanged) self.connect(self.mediaObject, QtCore.SIGNAL('aboutToFinish()'), self.aboutToFinish) Phonon.createPath(self.mediaObject, self.audioOutput) self.setupActions() self.setupMenus() self.setupUi() self.timeLcd.display("00:00") self.sources = []
def __init__(self): super(MainWindow, self).__init__() self.media = Phonon.MediaObject(self) self.audio = Phonon.AudioOutput(Phonon.MusicCategory, self) self.video = Phonon.VideoWidget(self) self.metaInformationResolver = Phonon.MediaObject(self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.media.setTickInterval(1000) self.sources = [] self.setupActions() self.setupConnections() self.setupUi() self.setWindowTitle("BLue PLayer") self.setMinimumSize(245,245) self.resize(680,400)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.setWindowFilePath('No file') # the media object controls the playback self.media = Phonon.MediaObject(self) # the audio output does the actual sound playback self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self) # a slider to seek to any given position in the playback self.seeker = Phonon.SeekSlider(self) self.setCentralWidget(self.seeker) # link media objects together. The seeker will seek in the created # media object self.seeker.setMediaObject(self.media) # audio data from the media object goes to the audio output object Phonon.createPath(self.media, self.audio_output) # set up actions to control the playback self.actions = self.addToolBar('Actions') for name, label, icon_name in self.ACTIONS: icon = self.style().standardIcon(icon_name) action = QAction(icon, label, self) action.setObjectName(name) self.actions.addAction(action) if name == 'open': action.triggered.connect(self._ask_open_filename) else: action.triggered.connect(getattr(self.media, name)) # whenever the playback state changes, show a message to the user self.media.stateChanged.connect(self._show_state_message)
def initializeAudioPhonon(self): if self.DEBUG: print "INFO: [Plugin:Orbit] Using Phonon Audio Framework" self.initializeAudioFilePath() self.media = Phonon.MediaObject() #print dir(self.media) audio = Phonon.AudioOutput(Phonon.MusicCategory) Phonon.createPath(self.media, audio) f = QtCore.QFile(self.audio_file) if f.exists(): source = Phonon.MediaSource(self.audio_file) if source.type() != -1: # -1 stands for invalid file self.media.setCurrentSource(source) self.media.play() else: if self.DEBUG: print "ERROR: [Plugin:Orbit] Audio control file invalid:", print self.audio_file else: if self.DEBUG: print "ERROR: [Plugin:Orbit] Audio control file does not exist:," print self.audio_file
def __init__(self, url=None, parent=None): QWidget.__init__(self) self.setWindowTitle('Video Player') # 再生ファイル self.url = url # Phonon Objects # *************** self.media = Phonon.MediaObject(self) self.video = Phonon.VideoWidget(self) # self.video.setMinimumSize(180, 280) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) # Timer # ***** self.media.setTickInterval(1 / 30 * 1000) # [ms] self.media.tick.connect(self.tock) self.time = 0 # UI 生成 # *************** self.setupUI()
def __init__(self, url=None, parent=None): QWidget.__init__(self) self.setWindowTitle('Audio Player') # 再生ファイル self.url = url # Phonon Objects # *************** self.media = Phonon.MediaObject(self) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) # Set SOURCE source = Phonon.MediaSource(self.url) self.media.setCurrentSource(source) # Timer # ***** self.media.setTickInterval(1 / 30 * 1000) # [ms] self.media.tick.connect(self.tock) self.time = 0 # UI 生成 # *************** self.setupUI()
def setup(self, parent): self.media = Phonon.MediaObject(parent) videoWidget = Phonon.VideoWidget(parent) Phonon.createPath(self.media, videoWidget) self.layout().addWidget(videoWidget) self.seekSlider = Phonon.SeekSlider(self.media, parent) self.layout().addWidget(self.seekSlider) self.seekSlider.setIconVisible(False) self.media.finished.connect(self.mediaFinished)
def __init__(self,audio=True,vibra=True): _d = NotifierDebug(); self._d = _d.d; self.manager = MNotificationManager('wazappnotify','WazappNotify'); self.vibra = vibra self.personalRingtone = WAConstants.DEFAULT_SOUND_NOTIFICATION; self.personalVibrate = True; self.groupRingtone = WAConstants.DEFAULT_SOUND_NOTIFICATION; self.groupVibrate = True; QCoreApplication.setApplicationName("Wazapp"); self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, None) self.mediaObject = Phonon.MediaObject(None) Phonon.createPath(self.mediaObject, self.audioOutput) self.profileChanged(0, 0, self.getCurrentProfile(), 0) bus = dbus.SessionBus() mybus = bus.get_object('com.nokia.profiled', '/com/nokia/profiled') self.nface = dbus.Interface(mybus, 'com.nokia.profiled') self.nface.connect_to_signal("profile_changed", self.profileChanged) #prof = self.getCurrentProfile() #reply = self.nface.get_value(prof,"ringing.alert.volume"); #self.currentProfile = prof #self.currentVolume = "1.0" if reply=="100" else "0." + reply #self._d("Checking current profile: " + prof + " - Volume: " + self.currentVolume) #self.audioOutput.setVolume(float(self.currentVolume)) #self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings self.devInfo = QSystemDeviceInfo(); #self.devInfo.currentProfileChanged.connect(self.profileChanged); self.audio = True '''if audio: self.audio = QMediaPlayer(None,QMediaPlayer.LowLatency); self.audio.setVolume(100); else: self.audio = False''' self.enabled = True self.notifications = {} # vibration comes too early here, now handled by ui.py when the message is already added in QML # well, the truth is that sound comes too late... :D #>> Any notification should be handler by the notifier, not UI :P I don't feel it's too early though, # but if necessary connect to a signal and vibrate from here. if self.vibra: self.vibra = QFeedbackHapticsEffect(); self.vibra.setIntensity(1.0); self.vibra.setDuration(200);
def get_widget_player(file_path, audio): media_src = Phonon.MediaSource(file_path) media_obj = Phonon.MediaObject() media_obj.setCurrentSource(media_src) video_widget = Phonon.VideoWidget() Phonon.createPath(media_obj, video_widget) if audio: audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(media_obj, audio_out) return media_obj, video_widget
def __init__(self, window): """ Creates a new AudioService :param window: QObject of the story ui """ self.media_object = Phonon.MediaObject(window) self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, window) Phonon.createPath(self.media_object, self.audio_output) self.filename_list = []
def play(self, filepath): global video_widget media_source = Phonon.MediaSource(filepath) media_obj = Phonon.MediaObject() media_obj.setCurrentSource(media_source) video_widget = Phonon.VideoWidget() Phonon.createPath(media_obj, video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(media_obj, audio_out) video_widget.show() media_obj.play()
def init_video(main_window): file_path = Utilities.OUTPUT_FOLDER + Utilities.CAMERA_FILE media_src = Phonon.MediaSource(file_path) main_window.media_obj = Phonon.MediaObject(main_window.wdgVideo) main_window.media_obj.setCurrentSource(media_src) main_window.video_widget = Phonon.VideoWidget(main_window.wdgVideo) Phonon.createPath(main_window.media_obj, main_window.video_widget) main_window.video_widget.setGeometry(main_window.wdgVideo.geometry()) main_window.video_widget.show() main_window.media_obj.play() main_window.media_obj.pause()
def __init__(self, parent = None ): super(Botonera, self).__init__(parent) self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self) self.media_obj = Phonon.MediaObject(self) self.setObjectName( 'Botonera' ) self.grid = flowlayout.FlowLayout() self.fillUi( PYFILEDIR + '/sounds' ) self.setupUi(self) wid = QtGui.QWidget() wid.setLayout( self.grid ) self.buttons_lay.addWidget( wid ) QtCore.QObject.connect( self.actionOpen_Folder, QtCore.SIGNAL( "triggered()" ), self.openFolder )
def __init__(self): Home.server = requests.session() self.output = Phonon.AudioOutput(Phonon.MusicCategory) self.m_media = Phonon.MediaObject() Phonon.createPath(self.m_media, self.output) QObject.connect(self.m_media, SIGNAL('finished()'), self.enqueueNextSource) self.home = HomeView() self.home.showNormal() self.home.setWindowTitle(u'customers caller app') self.home.label.setText(u"غير متصل") self.WS_OPEN()
def delayedInit(self): """ from http://techbase.kde.org/Development/Tutorials/Phonon/Introduction/Python """ if not self.m_media: self.m_media = Phonon.MediaObject(self) audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) Phonon.createPath(self.m_media, audioOutput) self.m_media.setCurrentSource( Phonon.MediaSource(\ self.separateInstance.files['inputAudioFilename'])) self.m_media.prefinishMarkReached.connect(self.playStop)
def create_media_object(self): """ Creates an instance of Phonon for playing songs in the parent application. PhononInstance.create_media_object() -> Phonon.MediaObject """ self._media_object = Phonon.MediaObject(self.parent) self._media_object.setTickInterval(1000) # Set the tick time to 1 sec self._media_object.tick.connect(self.on_tick) self._media_object.prefinishMarkReached.connect(self.halfway_reached) self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self.parent) Phonon.createPath(self._media_object, self.audio_output) return self._media_object
def __init__(self, parent=None): super(AudioPlayer, self).__init__(parent) self.setupUi(self) self.actionOpen.triggered.connect(self.open) self.actionQuit.triggered.connect(self.quite) self.horizontalSlider.setValue(0) self.horizontalSlider.setEnabled(False) self.horizontalSlider.sliderReleased.connect(self.slider_value_change) self.button.clicked.connect(self.play_or_pause) self.button.setText("Play") self.button.setEnabled(False) self.media_obj = Phonon.MediaObject(self) self.current_time = 0
def setUp(self): super(TestSimplePlaying, self).setUp() self.app.setApplicationName('Dummy') self.source = Phonon.MediaSource(sample_file) self.media = Phonon.MediaObject() self.media.setCurrentSource(self.source) self.media.finished.connect(self.app.quit) self.called = False # prevent locking with: # request to play a stream, but no valid audio ... self.output = Phonon.AudioOutput() self.path = Phonon.createPath(self.media, self.output)
def __init__(self, parent, mediaFiles): """ @type parent: QtGui.QWidget @type mediaFiles: gui.media.MediaFiles """ self.mediaObject = Phonon.MediaObject(parent) self.audioOutput = Phonon.AudioOutput(Phonon.NotificationCategory, parent) Phonon.createPath(self.mediaObject, self.audioOutput) self._sounds = { JobStatus.FAILING: Phonon.MediaSource(mediaFiles.failing_sound_path()), JobStatus.OK: Phonon.MediaSource(mediaFiles.ok_sound_path()), }
def test_phonon(): from PySide.phonon import Phonon a = app() # http://qt-project.org/doc/qt-4.8/phonon-overview.html#audio url = "z:/Users/jichi/tmp/test.mp3" print os.path.exists(url) mo = Phonon.MediaObject() audioOutput = Phonon.AudioOutput(Phonon.MusicCategory) path = Phonon.createPath(mo, audioOutput) #mo.setCurrentSource(Phonon.MediaSource(url)) mo.setCurrentSource(url) print mo.play() a.exec_()
def __init__(self, parent=None, data=None, data_fs=None, sample_freq=None, bd='float32', tick_interval=200): if bd not in bit_depths.values(): raise ValueError('Unsupported bit depth: %s' % bd) if tick_interval < 1: raise ValueError('tick_interval must be greater than zero.') super(PlayerToolBar, self).__init__(parent) self._audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) self._mediaObject = Phonon.MediaObject(self) self._mediaObject.setTickInterval(tick_interval) self._mediaObject.aboutToFinish.connect(self.about_to_finish) self._mediaObject.finished.connect(self.finished) self._mediaObject.currentSourceChanged.connect( self.current_source_changed) self._mediaObject.tick.connect(self.on_tick) self._mediaObject.stateChanged.connect(self.state_changed) self.connected = False self.connect_path() self._buffer = QtCore.QBuffer() self.buffer_loaded = False self._start = 0 self._end = np.inf self._interval_selected = False self._raw_data = None self.bd = bd if sample_freq is not None: self.sample_freq = float(sample_freq) else: self.sample_freq = None self._real_freq = None if data is not None: self.load_data(data, data_fs) else: self.data = None self._data_fs = None self.data_loaded = False self._init_ui()
def __init__(self): #QtGui.QWidget.__init__(self) super(QPlayer, self).__init__() self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self) self.player = Phonon.MediaObject(self) Phonon.createPath(self.player, self.audioOuptut) self.videoWidget = Phonon.VideoWidget(self) Phonon.createPath(self.player, self.videoWidget) self.player.setTickInterval(1000) self.connect(self.player, QtCore.SIGNAL("tick(qint64)"), self.tick) self.seekSlider = Phonon.SeekSlider(self.player, self) self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut, self) self.buildGUI() self.setupConnections()
def play_sound(self, alias): """ Plays a sound Arguments: alias (str): The name of a sound file alias as specified in a .qrc file, eg "mysound.wav" """ speakers = Phonon.AudioOutput(Phonon.MusicCategory, self) media = Phonon.MediaObject(self) speakers.setVolume(0.5) Phonon.createPath(media, speakers) media.setCurrentSource( ":/{}".format(alias) ) ### If we let the media file play all the way through, we get a nasty ### static squelch at the end. Set it to stop playing 30 milliseconds ### before the end. media.setPrefinishMark(30) media.prefinishMarkReached.connect( media.stop ) media.play()
def agregaCustomVideo(self): largo = 1904 if self.settingsPantallas[self.pantalla][2] == None: self.settingsPantallas[self.pantalla][2] = 1 multiplicador = self.settingsPantallas[self.pantalla][2] if multiplicador == 2: largo = 3820 if multiplicador == 3: largo = 5740 if multiplicador == 4: largo = 7660 customVideo, _ = QFileDialog.getOpenFileName(self, 'Cargar video') self.pantallaActiva.frame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.titleFrame.setVisible(False) self.pantallaActiva.graphFrame.setVisible(False) self.pantallaActiva.fotosFrame.setVisible(False) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry(0, 0, largo, 1050) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() self.settingsPantallas[self.pantalla][0] = "customVideo" self.settingsPantallas[self.pantalla][1] = customVideo self.settingsPantallas[self.pantalla][2] = multiplicador
def __init__(self, settings): super(QPlayer, self).__init__() self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self) self.player = Phonon.MediaObject(self) Phonon.createPath(self.player, self.audioOuptut) self.videoWidget = cVideoWidget() Phonon.createPath(self.player, self.videoWidget) self.player.setTickInterval(500) #1000 self.connect(self.player, QtCore.SIGNAL("tick(qint64)"), self.tick) self.seekSlider = Phonon.SeekSlider(self.player, self) self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut, self) #self.volumeSlider.setMaximumVolume(0.35) self.buildGUI() self.setupConnections() self.init = True # used to test before loading file when PLAY is pushed
def agregaCustomVideo(self): self.guion = False if self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] == None: self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] = 1 multiplicador = self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] self.extiendePantalla(multiplicador) largo = 1920 * multiplicador customVideo, _ = QFileDialog.getOpenFileName(self, 'Cargar video') #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry(0, 0, largo, 1080) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() self.settingsPantallas[ self.pantallaActivaIndex]['type'] = "customVideo" self.settingsPantallas[self.pantallaActivaIndex]['path'] = customVideo self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] = multiplicador
def __init__(self, parent=None): """ Setups the sound system. Ticks are not implemented because we don't need them but in case we do it is fairly simple. TODO what if there are no sound capabilities, is this sure at this point that we have them? """ super().__init__(parent=parent) # set up audio output and media object and connect both self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory, self) self.media_object = Phonon.MediaObject(self) Phonon.createPath(self.media_object, self.audio_output) # connect signal of media object self.media_object.stateChanged.connect(self.state_changed) self.media_object.aboutToFinish.connect(self.before_finish) # default values self.playlist = [] self.auto_rewind = True self.song_index = 0
def __init__(self): QtGui.QWidget.__init__(self) self.setWindowTitle('Video Player') self.media = Phonon.MediaObject(self) self.video = Phonon.VideoWidget(self) self.video.setMinimumSize(400, 400) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.buttonChoose = QtGui.QPushButton('Choose File', self) self.buttonMimes = QtGui.QPushButton('Show Mimetypes', self) self.slider = Phonon.VolumeSlider(self) self.slider.setAudioOutput(self.audio) layout = QtGui.QGridLayout(self) layout.addWidget(self.video, 0, 0, 1, 2) layout.addWidget(self.buttonChoose, 1, 0) layout.addWidget(self.buttonMimes, 1, 1) layout.addWidget(self.slider, 2, 0, 1, 2) layout.setRowStretch(0, 1) self.media.stateChanged.connect(self.handleStateChanged) self.buttonChoose.clicked.connect(self.handleButtonChoose) self.buttonMimes.clicked.connect(self.handleButtonMimes)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) # create two video widgets central = QWidget(self) self.setCentralWidget(central) layout = QHBoxLayout(central) central.setLayout(layout) self.left_video = Phonon.VideoWidget(self) self.right_video = Phonon.VideoWidget(self) layout.addWidget(self.left_video) layout.addWidget(self.right_video) # the media object controlling the video playback self.media = Phonon.MediaObject(self) # the audio sink self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) # connect the media object with audio and *left* video Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.left_video) # holds the Path object, that connects self.media with self.right_video self.right_path = None self.actions_toolbar = self.addToolBar('Actions') self._actions = {} for name, label, icon_name in self.ACTIONS: if icon_name: icon = self.style().standardIcon(icon_name) action = QAction(icon, label, self) else: action = QAction(label, self) action.setObjectName(name) if name in ('play', 'pause', 'stop'): action.triggered.connect(getattr(self.media, name)) else: action.triggered.connect(getattr(self, name)) self.actions_toolbar.addAction(action) self._action('remove_right_video').setEnabled(False)
def __init__(self): QtGui.QWidget.__init__(self) self.setWindowTitle('Speech Intelligibility Test') self.resize(800, 100) self.media = Phonon.MediaObject(self) self.audio = Phonon.AudioOutput(Phonon.MusicCategory, self) Phonon.createPath(self.media, self.audio) self.buttonStart = QtGui.QPushButton('Start', self) self.slider = Phonon.VolumeSlider(self) self.slider.setAudioOutput(self.audio) self.entry = QtGui.QLineEdit() self.entry.setEnabled(False) entryFont = QtGui.QFont("Times", 18) self.entry.setFont(entryFont) layout = QtGui.QGridLayout(self) layout.addWidget(self.entry, 0, 0, 1, 2) layout.addWidget(self.buttonStart, 1, 1) layout.addWidget(self.slider, 1, 0) layout.setRowStretch(0, 1) self.media.stateChanged.connect(self.handleStateChanged) self.media.finished.connect(self.handleSampleFinished) self.buttonStart.clicked.connect(self.handleButtonStart) self.entry.returnPressed.connect(self.handleSaveEntry)