Skip to content

Commit

Permalink
Will re-enable audio player on Linux (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed Jun 9, 2024
1 parent bb86083 commit 2def2b9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions buzz/widgets/transcription_viewer/transcription_viewer_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,19 @@ def __init__(
font = QFont(self.text_display_box.font().family(), 14)
self.text_display_box.setFont(font)

self.audio_player: Optional[AudioPlayer] = None
if platform.system() != "Linux":
self.audio_player = AudioPlayer(file_path=transcription.file)
self.audio_player.position_ms_changed.connect(
self.on_audio_player_position_ms_changed
)
self.audio_player = AudioPlayer(file_path=transcription.file)
self.audio_player.position_ms_changed.connect(
self.on_audio_player_position_ms_changed
)

self.current_segment_label = QLabel("", self)
self.current_segment_label.setAlignment(Qt.AlignmentFlag.AlignHCenter)
self.current_segment_label.setContentsMargins(0, 0, 0, 10)
self.current_segment_label.setWordWrap(True)

font_metrics = self.current_segment_label.fontMetrics()
max_height = font_metrics.lineSpacing() * 3
self.current_segment_label.setMaximumHeight(max_height)

layout = QVBoxLayout(self)

Expand Down Expand Up @@ -103,8 +106,7 @@ def __init__(

layout.addWidget(self.table_widget)
layout.addWidget(self.text_display_box)
if self.audio_player is not None:
layout.addWidget(self.audio_player)
layout.addWidget(self.audio_player)
layout.addWidget(self.current_segment_label)

self.setLayout(layout)
Expand All @@ -130,7 +132,7 @@ def on_view_mode_changed(self, is_timestamps: bool) -> None:
self.reset_view()

def on_segment_selected(self, segment: QSqlRecord):
if self.audio_player is not None and (
if (
self.audio_player.media_player.playbackState()
== QMediaPlayer.PlaybackState.PlayingState
):
Expand Down

0 comments on commit 2def2b9

Please sign in to comment.