def __init__(self, parent=None, num_decimals=2, bw_delta_secs=1, fw_delta_secs=1): """ """ self.num_decimals = num_decimals self.bw_delta_secs = bw_delta_secs self.fw_delta_secs = fw_delta_secs # super().__init__(parent) # self.play_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaPlay) self.pause_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaPause) self.stop_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaStop) self.bw_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaSeekBackward) self.fw_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaSeekForward) # first create player, then setup GUI, finally connect player to GUI self.media_player = QtMultimedia.QMediaPlayer(parent=self) self.media_player.setAudioRole(QtMultimedia.QAudio.MusicRole) # audio probe provides "real-time" readings from the source (the player) self.probe = QtMultimedia.QAudioProbe(parent=self) self.probe.setSource(self.media_player) self.probe.audioBufferProbed.connect(self.on_audio_probe) # self._setup_gui() self.media_player.stateChanged.connect(self.on_media_state_changed) # self.media_player.positionChanged.connect(self.on_pos_player_update) self.media_player.positionChanged.connect( lambda pos: self.on_pos_update(pos, "player")) self.media_player.error.connect(self.on_media_error) # this is needed to break the slider<->player update loop self._block_slider_player_loop = False # initialize with disabled buttons and zero range self.configure_gui(min_val=0, max_val=0, step=0.1, pos_secs=0, enable_buttons=False) # call this function to set the play/pause icon to media_player state self.on_media_state_changed() self.vol_s.setValue(50) # also initialize volume # self.current_qstream = None
def __init__(self, parent=None, max_allowed_secs=600): """ """ super().__init__(parent) self.setWindowTitle(self.WINDOW_TITLE) self.max_allowed_secs = max_allowed_secs # self.audio_recorder = QtMultimedia.QAudioRecorder(self) self.audio_recorder.durationChanged.connect(self.on_duration_changed) self.audio_recorder.statusChanged.connect(self.on_status_changed) # self.audio_recorder.stateChanged.connect(self.on_state_changed) # self.audio_probe = QtMultimedia.QAudioProbe(self) self.audio_probe.setSource(self.audio_recorder) self.audio_probe.audioBufferProbed.connect(self.on_audio_probe) # self._setup_gui() # self.vol_s.setValue(100) self.result = [] self.sample_rate = -1