本文整理汇总了Python中PyQt4.phonon.Phonon.createPlayer方法的典型用法代码示例。如果您正苦于以下问题:Python Phonon.createPlayer方法的具体用法?Python Phonon.createPlayer怎么用?Python Phonon.createPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.phonon.Phonon
的用法示例。
在下文中一共展示了Phonon.createPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# Create Phonon Music Player
self.phonon = Phonon.createPlayer(Phonon.MusicCategory)
self.phonon.stateChanged.connect(self.slotPhononStateChanged)
self.phonon.finished.connect(self.slotPhononPlaybackFinished)
# Connect signals for buttons
self.comboBoxUsers.currentIndexChanged.connect(self.reflectUserProperties)
self.pushButtonRecordSample.clicked.connect(self.slotShowRecordWindow)
# Enable button when item clicked
self.listWidgetEnrollments.itemClicked.connect(lambda: self.pushButtonPlay.setEnabled(True))
# Play sample if double-clicked
self.listWidgetEnrollments.itemDoubleClicked.connect(self.slotStartPlayback)
# Start/Stop Playback
self.pushButtonPlay.clicked.connect(self.slotStartPlayback)
self.pushButtonStop.clicked.connect(self.slotStopPlayback)
self.pushButtonTrain.clicked.connect(self.slotShowTrainingDialog)
self.pushButtonIdentify.clicked.connect(self.slotShowIdentifyDialog)
self.pushButtonAddSpeaker.clicked.connect(self.slotAddSpeaker)
self.pushButtonPlayTestingSample.clicked.connect(self.slotPlayTestingSample)
self.lineEditNewSpeaker.textEdited.connect(self.slotCheckNewSpeaker)
# Create Marf instance
self.marf = Marf()
# Fill speaker list
self.fill_speaker_list()
示例2: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, url, parent = None):
#url参数就是你的MP3地址
self.url = url
QtGui.QWidget.__init__(self, parent)
#设置一些窗口尺寸的策略,不用设置也会有默认策略,干脆注释了,无影响
# self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Preferred)
#创建一个音乐播放器 这是一种简单的方法,功能自然也是很单一,貌似只能实现简单的单首歌曲播放(希望我没有猜错,),更灵活的是使用AudioOutput,MediaObject等方法实现
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.setIcon(QtGui.QIcon('icons/49heart.svg')) #设置播放按钮图标,jpg,png都可以
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) #Label组件用来显示播放的当前时间
self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) #设置Label的对齐方式 左对齐或居中
layout = QtGui.QHBoxLayout(self) #水平布局
layout.addWidget(self.play_pause) #添加播放按钮
layout.addWidget(self.slider) #添加滑动条
layout.addWidget(self.status) #添加播放状态
示例3: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
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.setIcon(QtGui.QIcon(":/icons/player_play.svg"))
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)
示例4: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, parent = None):
self.url = "http://listen.radionomy.com/dubsideradio"
QtGui.QWidget.__init__(self, parent)
self.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Preferred)
self.player = Phonon.createPlayer(Phonon.MusicCategory,
Phonon.MediaSource(self.url))
self.player.setTickInterval(100)
self.player.tick.connect(self.tock)
self.play_pause = QtGui.QPushButton(self)
self.icon = QtGui.QIcon()
self.icon.addPixmap(QtGui.QPixmap(("image/play.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.play_pause.setIcon(self.icon)
self.play_pause.setIconSize(QtCore.QSize(23, 24))
self.icon2 = QtGui.QIcon()
self.icon2.addPixmap(QtGui.QPixmap(("image/pause.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.play_pause.setFlat(True)
self.play_pause.clicked.connect(self.playClicked)
self.player.stateChanged.connect(self.stateChanged)
self.slider = Phonon.SeekSlider(self.player , self)
self.setWindowIcon(self.icon)
self.status = QtGui.QLabel(self)
self.status.setAlignment(QtCore.Qt.AlignRight |
QtCore.Qt.AlignVCenter)
layout = QtGui.QHBoxLayout(self)
layout.addWidget(self.play_pause)
layout.addWidget(self.slider)
layout.addWidget(self.status)
示例5: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, listaRep):
self.listaRep = listaRep
self.cancion_actual = listaRep._head
self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory)
self.phonon = Phonon.MediaObject()
self.phonon = Phonon.createPlayer(Phonon.MusicCategory)
Phonon.createPath(self.phonon, self.audioOutput)
self.phonon.setCurrentSource(Phonon.MediaSource(self.cancion_actual.song.archivo))
示例6: play
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def play(self, filename):
if not self.music:
self.music = Phonon.createPlayer(Phonon.MusicCategory)
if self.music.state == Phonon.PlayingState:
self.music.enqueue(filename)
else:
self.music.enqueue(Phonon.MediaSource(filename));
self.music.play()
示例7: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__ (self):
self.audio = Phonon.createPlayer(Phonon.MusicCategory)
self.totalTime = 0
self.audioSource = None
self.audio.totalTimeChanged.connect(self.onTotalTimeChanged)
self.nowPlaying = None
self.library = MediaLibrary()
self.library.loadFromDirectory(r'C:\files\dropbox\music')
self.queue = MediaQueue(self.library)
示例8: init_phonon
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def init_phonon(self):
if not self.player:
self.player = Phonon.createPlayer(Phonon.MusicCategory)
self.m_audio = Phonon.AudioOutput(Phonon.MusicCategory, self)
Phonon.createPath(self.player, self.m_audio)
self.player.setTickInterval(100)
# actions
self.player.tick.connect(self.player_tick)
self.player.finished.connect(self.player_finished)
# QSlider -> SeekSlider
self.slider_time = Phonon.SeekSlider(self.player, self)
示例9: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, soundFile, POOL_COUNT=3):
self.state = True
self.soundFile = soundFile
self.resourcePool = deque()
self.current = None
self.POOL_COUNT = POOL_COUNT
for i in xrange(self.POOL_COUNT):
#self.resourcePool.append( QSound(soundFile) )
player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(soundFile));
self.resourcePool.append(player)
示例10: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, playList = [], ddir = "data"):
self._currentIndex = 0
try:
self._playList = playList
# 播放列表
self.playList = [Phonon.MediaSource(QUrl(item[1].format(DATA_DIR = ddir))) for item in self._playList]
# 播放器
self.player = Phonon.createPlayer(Phonon.MusicCategory)
self.player.setTickInterval(1000)
except Exception as e:
traceback.print_exc(e)
示例11: playURL
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def playURL(self, url):
"""Toma la URL de un playlist, y empieza a hacer ruido"""
data = parse_pls(url)
if data: # Tengo una URL
# Sí, tomamos el primer stream y listo.
url = data[0][1]
self.player = Phonon.createPlayer(Phonon.MusicCategory,
Phonon.MediaSource(url))
self.player.play()
else: # Pasó algo malo
QtGui.QMessageBox.information(None,
"Radio - Error reading playlist",
"Sorry, error starting this radio.")
示例12: playURL
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def playURL(self, url):
"""Toma la URL de un playlist, y empieza a hacer ruido"""
data = parse_pls(url)
if data: # Tengo una URL
# la anoto
self.playingURL = url
# Sí, tomamos el primer stream y listo.
url = data[0][1]
self.player = Phonon.createPlayer(Phonon.MusicCategory,
Phonon.MediaSource(url))
self.player.play()
# Notificar cada cambio en metaData (qué se esta escuchando)
self.player.metaDataChanged.connect(self.notify)
else: # Pasó algo malo
QtGui.QMessageBox.information(None,
self.tr("Radio - Error reading playlist"),
self.tr("Sorry, error starting this radio."))
示例13: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, parent=None):
super(MainWidget, self).__init__(parent)
# set app name before mediaObject was created to avoid phonon problem
QCoreApplication.setApplicationName("NetEaseMusic-ThirdParty")
self.ui = UiMainWidget()
self.ui.setup_ui(self)
self.signal_mapper = QSignalMapper(self)
self.player = Phonon.createPlayer(Phonon.MusicCategory)
self.net_manager = QNetworkAccessManager()
self.searchShortcut = QShortcut(QKeySequence("Ctrl+F"), self)
self.sources = []
self.net_ease = NetEase()
self.model = DataModel()
self.set_self_prop()
self.set_signal_binding()
self.init_table_widget()
示例14: __init__
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def __init__(self, autoProxy=False, parent=None) :
super(VocDialog, self).__init__(parent)
self.logger = getLogger('VocVoc.VocDialog')
self.info = self.logger.info
self.warn = self.logger.warn
self.debug = self.logger.debug
if autoProxy :
self.info('Starting VocDialog with autoProxy.')
else :
self.info('Starting VocDialog without autoProxy.')
self.mediaObeject = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(''))
self.setupUi()
self.connect()
self.initCountWord()
self.candidates = None
self.autoProxy = autoProxy
self.spellChecker = SpellChecker()
self.correct = self.spellChecker.correct
self.corpusDir = self.spellChecker.corpusDir
self.info('VocDialog started.')
示例15: play
# 需要导入模块: from PyQt4.phonon import Phonon [as 别名]
# 或者: from PyQt4.phonon.Phonon import createPlayer [as 别名]
def play(url):
if PLAYER == "phonon":
app = QApplication(sys.argv,
applicationName="Google Music playing test")
media = Phonon.createPlayer(Phonon.MusicCategory,
Phonon.MediaSource(url))
media.play()
# Trick to allow Ctrl+C to exit.
signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.exit(app.exec_())
elif PLAYER == "gst":
player = gst.element_factory_make("playbin2", "player")
player.set_property("uri", url)
player.set_state(gst.STATE_PLAYING)
glib.MainLoop().run()
else:
import subprocess
subprocess.call(["ffplay", "-vn", "-nodisp", "%s" % url])
return