Skip to content

toolbar

Classes:

PlaybackToolbar

PlaybackToolbar(main: MainWindow)

Bases: AbstractToolbar

Methods:

Attributes:

Source code
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def __init__(self, main: MainWindow) -> None:
    super().__init__(main, PlaybackSettings(self))
    self.setup_ui()

    self.play_buffer = deque[tuple[int, Future[vs.VideoFrame]]]()
    self.play_timer = Timer(timeout=self._show_next_frame, timerType=Qt.TimerType.PreciseTimer)

    self.play_timer_audio = Timer(timeout=self._play_next_audio_frame, timerType=Qt.TimerType.PreciseTimer)

    self.current_audio_output = cast(AudioOutput | None, None)
    self.current_audio_frame = Frame(0)
    self.play_buffer_audio = deque[Future[vs.AudioFrame]]()

    self.fps_history = deque[int]([], int(self.settings.FPS_AVERAGING_WINDOW_SIZE) + 1)
    self.current_fps = 0.0
    self.fps_timer = Timer(
        timeout=lambda: self.fps_spinbox.setValue(float(self.current_fps)), timerType=Qt.TimerType.PreciseTimer
    )

    self.play_start_time: int | None = None
    self.play_start_frame = Frame(0)
    self.play_end_time = 0
    self.play_end_frame = Frame(0)
    self.audio_outputs = cast(AudioOutputs, [])
    self.last_frame = Frame(0)

    self.setVolume(50, True)
    self.setMute(True)

    self.main.timeline.clicked.connect(self.on_timeline_clicked)

    self.set_qobject_names()

audio_outputs instance-attribute

audio_outputs: AudioOutputs = cast(AudioOutputs, [])

class_storable_attrs class-attribute instance-attribute

class_storable_attrs = tuple[str, ...](('settings', 'visibility'))

current_audio_frame instance-attribute

current_audio_frame = Frame(0)

current_audio_output instance-attribute

current_audio_output = cast(AudioOutput | None, None)

current_fps instance-attribute

current_fps = 0.0

fps_history instance-attribute

fps_history = deque[int]([], int(FPS_AVERAGING_WINDOW_SIZE) + 1)

fps_spinbox instance-attribute

fps_spinbox: DoubleSpinBox

fps_timer instance-attribute

fps_timer = Timer(
    timeout=lambda: setValue(float(current_fps)), timerType=PreciseTimer
)

got_debug_fps property

got_debug_fps: bool

hlayout instance-attribute

hlayout: HBoxLayout

is_notches_visible property

is_notches_visible: bool

last_frame instance-attribute

last_frame = Frame(0)

main instance-attribute

main: MainWindow = main

name instance-attribute

name: str = __name__[:-7]

notches_changed class-attribute instance-attribute

notches_changed = pyqtSignal(ExtendedWidget)

num_keys class-attribute instance-attribute

num_keys = [
    Key_1,
    Key_2,
    Key_3,
    Key_4,
    Key_5,
    Key_6,
    Key_7,
    Key_8,
    Key_9,
    Key_0,
]

play_buffer instance-attribute

play_buffer = deque[tuple[int, Future[VideoFrame]]]()

play_buffer_audio instance-attribute

play_buffer_audio = deque[Future[AudioFrame]]()

play_end_frame instance-attribute

play_end_frame = Frame(0)

play_end_time instance-attribute

play_end_time = 0

play_start_frame instance-attribute

play_start_frame = Frame(0)

play_start_time instance-attribute

play_start_time: int | None = None

play_timer instance-attribute

play_timer = Timer(timeout=_show_next_frame, timerType=PreciseTimer)

play_timer_audio instance-attribute

play_timer_audio = Timer(timeout=_play_next_audio_frame, timerType=PreciseTimer)

seek_frame_control instance-attribute

seek_frame_control: FrameEdit

settings instance-attribute

settings: PlaybackSettings

storable_attrs class-attribute instance-attribute

storable_attrs = ('audio_muted', 'audio_outputs', 'volume')

toggle_button instance-attribute

toggle_button = PushButton(name, self, checkable=True, clicked=on_toggle)

visibility instance-attribute

visibility = False

vlayout instance-attribute

vlayout: VBoxLayout

allocate_buffer

allocate_buffer(is_alpha: bool = False) -> None
Source code
198
199
200
201
202
203
204
205
206
207
208
209
210
211
def allocate_buffer(self, is_alpha: bool = False) -> None:
    if is_alpha:
        play_buffer_size = int(min(
            self.settings.playback_buffer_size,
            int(self.main.current_output.total_frames - self.main.current_output.last_showed_frame - 1) * 2
        ))
        play_buffer_size -= play_buffer_size % 2
    else:
        play_buffer_size = int(min(
            self.settings.playback_buffer_size,
            int(self.main.current_output.total_frames - self.main.current_output.last_showed_frame - 1)
        ))

    self.play_buffer = deque([], play_buffer_size)

get_notches

get_notches() -> Notches
Source code
405
406
407
def get_notches(self) -> Notches:
    from .custom import Notches
    return Notches()

get_separator

get_separator(horizontal: bool = False) -> QFrame
Source code
318
319
320
321
322
def get_separator(self, horizontal: bool = False) -> QFrame:
    separator = QFrame(self)
    separator.setFrameShape(QFrame.Shape.HLine if horizontal else QFrame.Shape.VLine)
    separator.setFrameShadow(QFrame.Shadow.Sunken)
    return separator

get_true_fps

get_true_fps(
    n: int | Frame, frameprops: FrameProps, force: bool = False
) -> Fraction
Source code
186
187
188
189
190
191
192
193
194
195
196
def get_true_fps(self, n: int | Frame, frameprops: vs.FrameProps, force: bool = False) -> Fraction:
    if (
        hasattr(self.main.current_output, 'got_timecodes') and self.main.current_output.got_timecodes and not force
    ):
        return Fraction(self.main.current_output.timecodes[int(n)])

    if any({x not in frameprops for x in {'_DurationDen', '_DurationNum'}}):
        raise RuntimeError(
            'Playback: DurationDen and DurationNum frame props are needed for VFR clips!'
        )
    return Fraction(frameprops['_DurationDen'], frameprops['_DurationNum'])  # type: ignore

init_notches

init_notches(main: MainWindow = ...) -> None
Source code
402
403
def init_notches(self, main: MainWindow = ...) -> None:
    self.notches_changed.connect(main.timeline.update_notches)

on_current_frame_changed

on_current_frame_changed(frame: Frame) -> None
Source code
471
472
def on_current_frame_changed(self, frame: Frame) -> None:
    pass

on_current_output_changed

on_current_output_changed(index: int, prev_index: int) -> None
Source code
175
176
177
178
179
180
def on_current_output_changed(self, index: int, prev_index: int) -> None:
    qt_silent_call(self.seek_frame_control.setMaximum, self.main.current_output.total_frames)
    qt_silent_call(self.seek_time_control.setMaximum, self.main.current_output.total_time)
    qt_silent_call(self.seek_time_control.setMinimum, Time(Frame(1)))
    qt_silent_call(self.seek_time_control.setValue, Time(self.seek_frame_control.value()))
    qt_silent_call(self.fps_spinbox.setValue, float(self.main.current_output.play_fps))

on_fps_changed

on_fps_changed(new_fps: Fraction) -> None
Source code
496
497
498
499
500
501
502
503
504
def on_fps_changed(self, new_fps: Fraction) -> None:
    if not self.fps_spinbox.isEnabled() or not self.main.current_output:
        return

    self.main.current_output.play_fps = new_fps

    if self.play_timer.isActive():
        self.stop()
        self.play()

on_fps_unlimited_changed

on_fps_unlimited_changed(state: CheckState) -> None
Source code
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
def on_fps_unlimited_changed(self, state: Qt.CheckState) -> None:
    if state == Qt.CheckState.Checked:
        self.fps_spinbox.setEnabled(False)
        self.fps_reset_button.setEnabled(False)
        self.fps_variable_checkbox.setChecked(False)
        self.fps_variable_checkbox.setEnabled(False)
    elif state == Qt.CheckState.Unchecked:
        self.fps_spinbox.setEnabled(True)
        self.fps_reset_button.setEnabled(True)
        self.fps_spinbox.setValue(float(self.main.current_output.play_fps))
        self.fps_variable_checkbox.setEnabled(True)

    if self.play_timer.isActive():
        self.stop()
        self.play()

on_fps_variable_changed

on_fps_variable_changed(state: CheckState) -> None
Source code
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
def on_fps_variable_changed(self, state: Qt.CheckState) -> None:
    if state == Qt.CheckState.Checked:
        self.fps_spinbox.setEnabled(False)
        self.fps_reset_button.setEnabled(False)
        self.fps_unlimited_checkbox.setEnabled(False)
        self.fps_unlimited_checkbox.setChecked(False)
    elif state == Qt.CheckState.Unchecked:
        self.fps_spinbox.setEnabled(True)
        self.fps_reset_button.setEnabled(True)
        self.fps_unlimited_checkbox.setEnabled(True)
        self.fps_spinbox.setValue(float(self.main.current_output.play_fps))

    if self.play_timer.isActive():
        self.stop()
        self.play()

on_mute_clicked

on_mute_clicked() -> None
Source code
565
566
567
568
569
570
571
572
def on_mute_clicked(self) -> None:
    if not hasattr(self, 'audio_outputs_combobox'):
        return

    if self.volume == 0 and self.audio_muted:
        self.setVolume(50, True)
    else:
        self.setMute(not self.audio_muted)

on_play_n_frames_clicked

on_play_n_frames_clicked(checked: bool) -> None
Source code
490
491
492
493
494
def on_play_n_frames_clicked(self, checked: bool) -> None:
    if checked:
        self.play(Frame(self.main.current_output.last_showed_frame) + Frame(self.seek_frame_control.value()))
    else:
        self.stop()

on_play_pause_clicked

on_play_pause_clicked(checked: bool) -> None
Source code
464
465
466
467
468
def on_play_pause_clicked(self, checked: bool) -> None:
    if checked:
        self.play()
    else:
        self.stop()

on_seek_frame_changed

on_seek_frame_changed(frame: Frame | None) -> None
Source code
454
455
456
457
def on_seek_frame_changed(self, frame: Frame | None) -> None:
    if frame is None:
        return
    qt_silent_call(self.seek_time_control.setValue, Time(frame))

on_seek_time_changed

on_seek_time_changed(time: Time | None) -> None
Source code
459
460
461
462
def on_seek_time_changed(self, time: Time | None) -> None:
    if time is None:
        return
    qt_silent_call(self.seek_frame_control.setValue, Frame(time))

on_timeline_clicked

on_timeline_clicked(frame: Frame, time: Time) -> None
Source code
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
def on_timeline_clicked(self, frame: Frame, time: Time) -> None:
    if (
        not self.play_timer.isActive() or not self.play_timer_audio.isActive() or self.current_audio_output is None
    ) or self.current_audio_output.vs_output is None:
        return

    self.current_audio_output.iodevice.reset()
    self.current_audio_frame = self.current_audio_output.to_frame(time)

    for future in self.play_buffer_audio:
        future.add_done_callback(lambda future: future.result())

    self.play_buffer_audio.clear()

    for i in range(0, cast(int, self.play_buffer_audio.maxlen)):
        future = self.current_audio_output.vs_output.get_frame_async(  # type: ignore
            int(self.current_audio_frame + Frame(i + 1))
        )
        self.play_buffer_audio.appendleft(future)

on_toggle

on_toggle(new_state: bool) -> None
Source code
461
462
463
464
465
466
467
468
469
def on_toggle(self, new_state: bool) -> None:
    if new_state == self.visibility:
        return

    # invoking order matters
    self.setVisible(new_state)
    self.visibility = new_state
    self.toggle_button.setChecked(new_state)
    self.resize_main_window(new_state)

play

play(stop_at_frame: int | Frame | None = None) -> None
Source code
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
def play(self, stop_at_frame: int | Frame | None = None) -> None:
    if (
        self.main.current_output.last_showed_frame > self.main.current_output.total_frames
    ):
        return

    if not PackingType.CURRENT.can_playback:
        import logging
        logging.warn(
            f'The current backend ({PackingType.CURRENT.name}) can\'t playback! Install akarin or libp2p plugins.'
        )
        return

    if self.main.statusbar.label.text() == 'Ready':
        self.main.statusbar.label.setText('Playing')

    if self.main.current_output.prepared.alpha is None:
        self.allocate_buffer(False)
        for i in range(cast(int, self.play_buffer.maxlen)):
            nextFrame = int(Frame(self.main.current_output.last_showed_frame) + i + 1)
            if nextFrame >= self.main.current_output.total_frames:
                break
            self.play_buffer.appendleft(
                (nextFrame, self.main.current_output.prepared.clip.get_frame_async(nextFrame))  # type: ignore
            )
    else:
        self.allocate_buffer(True)
        for i in range(cast(int, self.play_buffer.maxlen) // 2):
            nextFrame = int(Frame(self.main.current_output.last_showed_frame) + i + 1)
            if nextFrame >= self.main.current_output.total_frames:
                break
            self.play_buffer.appendleft(
                (nextFrame, self.main.current_output.prepared.clip.get_frame_async(nextFrame))  # type: ignore
            )
            self.play_buffer.appendleft(
                (nextFrame, self.main.current_output.prepared.alpha.get_frame_async(nextFrame))  # type: ignore
            )

    self.last_frame = Frame(stop_at_frame or (self.main.current_output.total_frames - 1))

    if self.fps_unlimited_checkbox.isChecked() or self.got_debug_fps:
        self.mute_button.setChecked(True)
        self.play_timer.start(0)
        if self.got_debug_fps:
            self.play_start_time = perf_counter_ns()
            self.play_start_frame = Frame(self.main.current_output.last_showed_frame)
        else:
            self.fps_timer.start(self.settings.FPS_REFRESH_INTERVAL)
    else:
        if self.fps_variable_checkbox.isChecked() and self.main.current_output._stateset:
            fps = self.get_true_fps(self.last_frame, self.main.current_output.props)
        else:
            fps = self.main.current_output.play_fps

        self.play_timer.start(floor(1000 / fps))

    self.current_audio_output = self.audio_outputs_combobox.currentValue()

    if not self.audio_muted and self.current_audio_output is not None:
        self.play_audio()

play_audio

play_audio() -> None
Source code
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
def play_audio(self) -> None:
    if not len(self.audio_outputs):
        return

    self.current_audio_output = self.audio_outputs_combobox.currentValue()

    if not self.current_audio_output.vs_output:
        return

    self.audio_outputs_combobox.setEnabled(False)
    self.current_audio_frame = self.current_audio_output.to_frame(
        Time(self.main.current_output.last_showed_frame)
    )

    self.current_audio_output.render_audio_frame(self.current_audio_frame)
    self.current_audio_output.render_audio_frame(self.current_audio_frame + Frame(1))
    self.current_audio_output.render_audio_frame(self.current_audio_frame + Frame(2))

    self.play_buffer_audio = deque([], int(min(
        self.settings.playback_buffer_size,
        int(self.current_audio_output.total_frames - self.current_audio_frame - 1)
    )))

    for i in range(2, cast(int, self.play_buffer_audio.maxlen)):
        self.play_buffer_audio.appendleft(
            self.current_audio_output.vs_output.get_frame_async(  # type: ignore
                int(self.current_audio_frame + i + 1)
            )
        )

    self.play_timer_audio.start(
        floor(
            1000 / self.current_audio_output.fps / self.main.current_output.play_fps * self.main.current_output.fps
        )
    )

rescan_outputs

rescan_outputs(outputs: AudioOutputs | None = None) -> None
Source code
182
183
184
def rescan_outputs(self, outputs: AudioOutputs | None = None) -> None:
    self.audio_outputs = outputs if isinstance(outputs, AudioOutputs) else AudioOutputs(self.main)
    self.audio_outputs_combobox.setModel(self.audio_outputs)

reset_fps

reset_fps(checked: bool | None = None) -> None
Source code
506
507
def reset_fps(self, checked: bool | None = None) -> None:
    self.fps_spinbox.setValue(self.main.current_output.fps_num / self.main.current_output.fps_den)

resize_main_window

resize_main_window(expanding: bool) -> None
Source code
481
482
483
484
485
486
487
488
489
def resize_main_window(self, expanding: bool) -> None:
    if self.main.windowState() in {Qt.WindowState.WindowMaximized, Qt.WindowState.WindowFullScreen}:
        return

    if expanding:
        self.main.resize(self.main.width(), self.main.height() + self.height() + round(6 * self.main.display_scale))
    if not expanding:
        self.main.resize(self.main.width(), self.main.height() - self.height() - round(6 * self.main.display_scale))
        self.main.timeline.update()

seek_offset

seek_offset(offset: int) -> None
Source code
443
444
445
446
447
448
449
450
451
452
def seek_offset(self, offset: int) -> None:
    new_pos = self.main.current_output.last_showed_frame + offset

    if not 0 <= new_pos < self.main.current_output.total_frames:
        return

    if self.play_timer.isActive():
        self.stop()

    self.main.switch_frame(new_pos)

seek_to_end

seek_to_end(checked: bool | None = None) -> None
Source code
439
440
441
def seek_to_end(self, checked: bool | None = None) -> None:
    self.stop()
    self.main.switch_frame(self.main.current_output.total_frames - 1)

seek_to_start

seek_to_start(checked: bool | None = None) -> None
Source code
435
436
437
def seek_to_start(self, checked: bool | None = None) -> None:
    self.stop()
    self.main.switch_frame(Frame(0))

setMute

setMute(isMuted: bool) -> None
Source code
574
575
576
577
578
579
580
581
582
583
def setMute(self, isMuted: bool) -> None:
    self.audio_muted = isMuted

    if not isMuted:
        if self.play_timer.isActive() and not self.play_timer_audio.isActive():
            self.play_audio()
    elif self.play_timer_audio.isActive():
        self.stop_audio()

    self.updateMuteGui()

setVolume

setVolume(newVolume: float, updateGui: bool = False) -> None
Source code
585
586
587
588
589
590
591
592
593
594
595
def setVolume(self, newVolume: float, updateGui: bool = False) -> None:
    self.volume = newVolume

    self.setMute(self.volume == 0)

    if newVolume:
        for output in self.audio_outputs:
            output.volume = newVolume / 100.0

    if updateGui:
        qt_silent_call(self.audio_volume_slider.setValue, self.volume)

set_qobject_names

set_qobject_names() -> None
Source code
279
280
281
282
283
284
285
286
287
288
289
290
291
292
def set_qobject_names(self) -> None:
    if not hasattr(self, '__slots__'):
        return

    slots = list(self.__slots__)

    if isinstance(self, AbstractToolbar) and 'main' in slots:
        slots.remove('main')

    for attr_name in slots:
        attr = getattr(self, attr_name)
        if not isinstance(attr, QObject):
            continue
        attr.setObjectName(type(self).__name__ + '.' + attr_name)

setup_ui

setup_ui() -> None
Source code
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
def setup_ui(self) -> None:
    super().setup_ui()

    self.seek_to_start_button = PushButton(
        '⏮', self, tooltip='Seek to First Frame', clicked=self.seek_to_start
    )

    self.seek_n_frames_b_button = PushButton(
        '⏪', self, tooltip='Seek N Frames Backwards',
        clicked=lambda _: self.seek_offset(self.seek_frame_control.value() * -1)  # type: ignore
    )

    self.seek_to_prev_button = PushButton(
        '⏪', self, tooltip='Seek 1 Frame Backwards', clicked=lambda _: self.seek_offset(-1)
    )

    self.play_pause_button = PushButton(
        '⏯', self, tooltip='Play/Pause', checkable=True, clicked=self.on_play_pause_clicked
    )

    self.seek_to_next_button = PushButton(
        '⏩', self, tooltip='Seek 1 Frame Forward', clicked=lambda _: self.seek_offset(1)
    )

    self.seek_n_frames_f_button = PushButton(
        '⏩', self, tooltip='Seek N Frames Forward',
        clicked=lambda _: self.seek_offset(self.seek_frame_control.value())  # type: ignore
    )

    self.seek_to_end_button = PushButton(
        '⏭', self, tooltip='Seek to Last Frame', clicked=self.seek_to_end
    )

    self.seek_frame_control = FrameEdit(
        self, 1, value=self.settings.SEEK_STEP, tooltip='Seek N Frames Step',
        valueChanged=self.on_seek_frame_changed
    )

    self.play_n_frames_button = PushButton(
        '⏯', self, tooltip='Play N Frames', checkable=True, clicked=self.on_play_n_frames_clicked
    )

    self.seek_time_control = TimeEdit(self, valueChanged=self.on_seek_time_changed)

    self.fps_spinbox = DoubleSpinBox(self, valueChanged=self.on_fps_changed)
    self.fps_spinbox.setRange(0.001, 9999.0)
    self.fps_spinbox.setDecimals(3)
    self.fps_spinbox.setSuffix(' fps')

    self.fps_reset_button = PushButton('Reset FPS', self, clicked=self.reset_fps)

    self.fps_unlimited_checkbox = CheckBox('Unlimited FPS', self, stateChanged=self.on_fps_unlimited_changed)

    self.fps_variable_checkbox = CheckBox('Variable FPS', self, stateChanged=self.on_fps_variable_changed)

    self.mute_button = PushButton('', self, clicked=self.on_mute_clicked)
    self.mute_button.setFixedWidth(18)

    self.audio_outputs_combobox = ComboBox[AudioOutput](
        self, editable=True, insertPolicy=QComboBox.InsertPolicy.InsertAtCurrent,
        duplicatesEnabled=True, sizeAdjustPolicy=QComboBox.SizeAdjustPolicy.AdjustToContents
    )

    self.audio_volume_slider = QSlider(Qt.Orientation.Horizontal, valueChanged=self.setVolume)  # type: ignore
    self.audio_volume_slider.setFocusPolicy(Qt.FocusPolicy.NoFocus)
    self.audio_volume_slider.setFixedWidth(120)
    self.audio_volume_slider.setRange(0, 100)
    self.audio_volume_slider.setPageStep(5)

    self.hlayout.addWidgets([
        self.seek_to_start_button, self.seek_n_frames_b_button, self.seek_to_prev_button,
        self.play_pause_button,
        self.seek_to_next_button, self.seek_n_frames_f_button, self.seek_to_end_button,
        self.seek_frame_control, self.play_n_frames_button,
        self.seek_time_control,
        self.fps_spinbox, self.fps_reset_button,
        self.fps_unlimited_checkbox, self.fps_variable_checkbox,
        self.get_separator(),
        self.audio_outputs_combobox, self.mute_button, self.audio_volume_slider
    ])

    self.hlayout.addStretch()

stop

stop() -> None
Source code
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
def stop(self) -> None:
    import gc
    import logging

    if not self.play_timer.isActive():
        return

    self.play_timer.stop()

    if self.got_debug_fps and self.play_start_time is not None:
        self.play_end_time = perf_counter_ns()
        self.play_end_frame = Frame(self.main.current_output.last_showed_frame)
    if self.main.statusbar.label.text() == 'Playing':
        self.main.statusbar.label.setText('Ready')

    for future in self.play_buffer:
        future[1].add_done_callback(_del_future)

    self.play_buffer.clear()
    del self.play_buffer

    gc.collect(generation=2)

    self.current_audio_output = self.audio_outputs_combobox.currentValue()

    if not self.audio_muted and self.current_audio_output is not None:
        self.stop_audio()

    self.fps_history.clear()
    self.fps_timer.stop()

    if self.play_start_time is not None and self.got_debug_fps:
        time_interval = (self.play_end_time - self.play_start_time) / 1_000_000_000
        frame_interval = self.play_end_frame - self.play_start_frame
        logging.debug(
            f'{time_interval:.3f} s, {frame_interval} frames, {int(frame_interval) / time_interval:.3f} fps'
        )
        self.play_start_time = None

stop_audio

stop_audio() -> None
Source code
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
def stop_audio(self) -> None:
    if self.current_audio_output is None:
        return

    self.current_audio_output.iodevice.reset()

    self.play_timer_audio.stop()

    for future in self.play_buffer_audio:
        future.add_done_callback(_del_future)  # type: ignore

    self.play_buffer_audio.clear()

    self.current_audio_frame = Frame(0)
    self.audio_outputs_combobox.setEnabled(True)

updateMuteGui

updateMuteGui() -> None
Source code
555
556
557
558
559
560
561
562
563
def updateMuteGui(self) -> None:
    if self.volume == 0 or self.audio_muted:
        self.mute_button.setText('🔇')
    elif self.volume <= 33:
        self.mute_button.setText('🔈')
    elif self.volume <= 66:
        self.mute_button.setText('🔉')
    else:
        self.mute_button.setText('🔊')

update_fps_counter

update_fps_counter() -> None
Source code
541
542
543
544
545
546
547
548
549
550
551
552
553
def update_fps_counter(self) -> None:
    if self.fps_spinbox.isEnabled():
        return

    self.fps_history.append(perf_counter_ns())
    if len(self.fps_history) == 1:
        return

    elapsed_total = 0
    for i in range(len(self.fps_history) - 1):
        elapsed_total += self.fps_history[i + 1] - self.fps_history[i]

    self.current_fps = 1_000_000_000 / (elapsed_total / len(self.fps_history))