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


Python QtMultimedia.QMediaContent方法代码示例

本文整理汇总了Python中PyQt5.QtMultimedia.QMediaContent方法的典型用法代码示例。如果您正苦于以下问题:Python QtMultimedia.QMediaContent方法的具体用法?Python QtMultimedia.QMediaContent怎么用?Python QtMultimedia.QMediaContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtMultimedia的用法示例。


在下文中一共展示了QtMultimedia.QMediaContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: play

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def play(self):
        try:
            media = self.musics[self.currentIndex]
        except:
            logger.error("unknow error. musics info: {0}".format(self.musics))
            return

        if type(media) == str:
            if 'http' in media or 'file' in media:
                content = QMediaContent(QUrl(media))
            else:
                content = QMediaContent(QUrl.fromLocalFile(media))

            self.musics = self.musics[:self.currentIndex] + [content] + self.musics[self.currentIndex+1:]
            media = content

        self.parent.setMedia(media)
        self.parent.playMusic()

        self.tabMusicEvent() 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:22,代码来源:player.py

示例2: setCurrentIndex

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def setCurrentIndex(self, index):
        try:
            media = self.musics[index]
        except:
            logger.error("unknow error. musics info: {0}".format(self.musics))
            return

        if type(media) == str:
            if 'http' in media or 'file' in media:
                content = QMediaContent(QUrl(media))
            else:
                content = QMediaContent(QUrl.fromLocalFile(media))

            self.musics = self.musics[:index] + [content] + self.musics[index+1:]
            self.parent.setMedia(content)
        else:
            self.parent.setMedia(media)

        self.parent.playMusic()
        self.tabMusicEvent()

        self.currentIndex = index 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:24,代码来源:player.py

示例3: load_soundtrack_playlist

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def load_soundtrack_playlist():
    """
    Loads the play list of the soundtracks and replaces the file name with the full path.

    A playlist is a list where each entry is a list of two strings: file path, title
    """
    global soundtrack_playlist

    # create playlist
    soundtrack_playlist = QtMultimedia.QMediaPlaylist()
    soundtrack_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop)

    # read information file
    data = utils.read_as_yaml(constants.SOUNDTRACK_INFO_FILE)

    # add the soundtrack folder to each file name
    for entry in data:
        file = constants.extend(constants.SOUNDTRACK_FOLDER, entry[0])
        url = qt.local_url(file)
        media = QtMultimedia.QMediaContent(url)
        soundtrack_playlist.addMedia(media) 
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:23,代码来源:audio.py

示例4: play_song

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def play_song(self, song: str):
        """Play a song given its file url in the local filesystem."""
        self.player.playlist().clear()
        self.controls.duration_label.setText('Loading...')
        url = QtCore.QUrl.fromLocalFile(song)

        if self.check_advert_intermission():
            self.player.playlist().addMedia(QtMultimedia.QMediaContent(url))
        else:
            self.player.playlist().insertMedia(
                self.player.playlist().nextIndex(),
                QtMultimedia.QMediaContent(url)
            )

            if self.player.playlist().mediaCount() == 1:
                self.controls.toggle_play()
            else:
                self.controls._next_song()
        self.controls.duration_label.setText('0')
        self.controls.play_pause_button.setIcon(QtGui.QIcon(imgButtons.Pause.str)) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:22,代码来源:music_player.py

示例5: play_pronunciation

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def play_pronunciation(self):
        if not self.pronunciation_mp3 or not multimedia_available:
            return

        media_content = QtMultimedia.QMediaContent(
            QtCore.QUrl(self.pronunciation_mp3))

        player = QtMultimedia.QMediaPlayer(self)
        player.setMedia(media_content)
        player.play() 
开发者ID:BasioMeusPuga,项目名称:Lector,代码行数:12,代码来源:definitionsdialog.py

示例6: set_source

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def set_source(self, audio_path):
        url = QUrl.fromLocalFile(audio_path)
        media = QMediaContent(url)
        self.setNotifyInterval(35)
        self.setMedia(media) 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:7,代码来源:playback.py

示例7: setMusic

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def setMusic(self, url, data):
        """设置当前的音乐,可以直接用网络链接。"""
        if url:
            if 'http' in url or 'file' in url:
                self.playList.addMedias(QMediaContent(QUrl(url)), data)
            else:
                self.playList.addMedias(QMediaContent(QUrl.fromLocalFile(url)), data)
            return True
        return False 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:11,代码来源:player.py

示例8: addMedias

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def addMedias(self, url, data):
        # url为QMediaContent, data包含这个歌曲的信息。{name, author, url, music_id}
        self.parent.setMedia(url)
        self.musics.append(url)
        self.currentIndex = len(self.musics) - 1
        self.mediaList[url.canonicalUrl().toString()] = data
        self.parent.playMusic()
        
        # window
        self.playWidgets.parent.systemTray.setToolTip('{0}-{1}'.format(data['name'], data['author'])) 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:12,代码来源:player.py

示例9: saveCookies

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def saveCookies(self):
        with open(self.musicsCookiesFolder, 'wb') as f:
            for row, data in enumerate(self.musics):
                if type(data) == QMediaContent:
                    url = data.canonicalUrl().toString()
                    self.musics[row] = url

            pickle.dump(self.musics, f)

        with open(self.mediaListCookiesFolder, 'wb') as f:
            pickle.dump(self.mediaList, f) 
开发者ID:HuberTRoy,项目名称:MusicBox,代码行数:13,代码来源:player.py

示例10: setMediaUrl

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def setMediaUrl(self, url):
        if url.startswith('http'):
            _url = QUrl(url)
        else:
            _url = QUrl.fromLocalFile(url)

        gPlayer.setMedia(QMediaContent(_url))
        self.playToggle(self._isPlaying) 
开发者ID:dragondjf,项目名称:QMusic,代码行数:10,代码来源:mediaplayer.py

示例11: addMedia

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def addMedia(self, media_file):
        media_content = QMediaContent(QUrl.fromLocalFile(media_file))
        self._playlist.addMedia(media_content)

    # クリックでポーズ・再生の切り替え 
开发者ID:tody411,项目名称:PyIntroduction,代码行数:7,代码来源:media_player.py

示例12: set_file

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def set_file(self, url):
        self.label.setText(url.fileName())
        if url.scheme() == '':
            url.setScheme('file')
        content = qtmm.QMediaContent(url)
        #self.player.setMedia(content)
        # Looping
        # must retain a reference to the playlist
        # hence self.playlist
        self.playlist = qtmm.QMediaPlaylist()
        self.playlist.addMedia(content)
        self.playlist.setCurrentIndex(1)
        self.player.setPlaylist(self.playlist)
        self.loop_cb.setChecked(False) 
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:16,代码来源:soundboard.py

示例13: on_file_selected

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def on_file_selected(self, item):
        fn = item.text()
        url = qtc.QUrl.fromLocalFile(self.video_dir.filePath(fn))
        content = qtmm.QMediaContent(url)
        self.player.setMedia(content)
        self.player.play()

    #######################
    # Recording callbacks #
    ####################### 
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:12,代码来源:captains_log.py

示例14: _media_changed

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def _media_changed(self, media: QtMultimedia.QMediaContent):
        """Update 'Now playing' label when a new song is selected."""
        filename = media.canonicalUrl().fileName()
        song_name = '.'.join(filename.split('.')[:-1])
        self.now_playing_label.setText(song_name) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:7,代码来源:now_playing.py

示例15: disable_advert_controls

# 需要导入模块: from PyQt5 import QtMultimedia [as 别名]
# 或者: from PyQt5.QtMultimedia import QMediaContent [as 别名]
def disable_advert_controls(self, media: QtMultimedia.QMediaContent):
        """Disable player controls while an ad is playing."""
        if self.advert_in_progress:
            self.now_playing_widget.audio_visualiser.green_flames()
            self.controls.setEnabled(False)
            self.advert_in_progress = False
        else:
            self.now_playing_widget.audio_visualiser.red_flames()
            self.controls.setEnabled(True) 
开发者ID:python-discord,项目名称:code-jam-5,代码行数:11,代码来源:music_player.py


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