Ejemplo n.º 1
0
    def mouseReleaseEvent(self, event: Qt.QMouseEvent):
        super().mouseReleaseEvent(event)

        file_name = self.dog_sound_1 if event.button(
        ) == Qt.Qt.LeftButton else self.dog_sound_2
        file_name = Qt.QUrl.fromLocalFile(file_name)
        self.player.setMedia(Qt.QMediaContent(file_name))
        self.player.play()
Ejemplo n.º 2
0
 def vasa(self):
     sender = self.sender()
     if self.audio!=None:
         player.setMedia(Qt.QMediaContent(Qt.QUrl.fromLocalFile(self.audio)))
         player.play()
     if sender.text()==self.ru_to_translate:
         self.setStyleSheet("*{ background-color: green }")
     else:
         self.setStyleSheet("*{ background-color: red }")
Ejemplo n.º 3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'


from PyQt5 import Qt


def _on_media_status_changed(status):
    if status == Qt.QMediaPlayer.EndOfMedia:
        Qt.QCoreApplication.instance().quit()


app = Qt.QCoreApplication([])

player = Qt.QMediaPlayer()
file_name = Qt.QUrl.fromLocalFile('example.mp3')
player.setMedia(Qt.QMediaContent(file_name))
player.mediaStatusChanged.connect(_on_media_status_changed)
player.play()

app.exec()