当前位置: 首页>>代码示例>>Python>>正文


Python Phonon.createPlayer方法代码示例

本文整理汇总了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()
开发者ID:ozancaglayan,项目名称:SPID,代码行数:36,代码来源:main.py

示例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)  #添加播放状态
开发者ID:codeAB,项目名称:MMusic,代码行数:32,代码来源:ceshi2.py

示例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)
开发者ID:homoludens,项目名称:py_examples,代码行数:31,代码来源:audiowidget.py

示例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)
开发者ID:mrwolfs,项目名称:PostPro-Charlie-Bill,代码行数:37,代码来源:AudioPlayer.py

示例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))
开发者ID:ajerit,项目名称:python-projects,代码行数:10,代码来源:rep.py

示例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()
开发者ID:wojas,项目名称:pomni,代码行数:11,代码来源:sound.py

示例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)
开发者ID:calonx,项目名称:Code,代码行数:12,代码来源:musician.py

示例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)
开发者ID:thrstnh,项目名称:playground,代码行数:13,代码来源:main.py

示例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)
开发者ID:sfgorky,项目名称:bouncing_ball,代码行数:13,代码来源:SoundCell.py

示例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)
开发者ID:892768447,项目名称:BlogClient,代码行数:13,代码来源:player2.py

示例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.")
开发者ID:davidlarizap,项目名称:python-no-muerde,代码行数:17,代码来源:radio7.py

示例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."))
开发者ID:davidlarizap,项目名称:python-no-muerde,代码行数:20,代码来源:radio9.py

示例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()
开发者ID:alexmao86,项目名称:NetEaseMusic,代码行数:20,代码来源:controllers.py

示例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.')
开发者ID:NicholasTD07,项目名称:VocVoc,代码行数:22,代码来源:interface.py

示例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
开发者ID:ntw,项目名称:Unofficial-Google-Music-API,代码行数:22,代码来源:example_play.py


注:本文中的PyQt4.phonon.Phonon.createPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。