Revert "Allow <audio> to play without user interaction in accordance to autoplay setting"

This reverts commit 54f51da944.

This breaks in the PyQt6 upgrade. There are no globals anymore, only
page profiles - but the code should probably be modifying a specific
webview instead of globals anyway.
This commit is contained in:
Damien Elmes 2021-10-05 09:10:20 +10:00
parent 69c196b409
commit aabf693bb8
4 changed files with 0 additions and 13 deletions

View file

@ -209,7 +209,6 @@ class Previewer(QDialog):
bodyclass = theme_manager.body_classes_for_card_ord(c.ord) bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
if c.autoplay(): if c.autoplay():
AnkiWebView.setPlaybackRequiresGesture(False)
if self._show_both_sides: if self._show_both_sides:
# if we're showing both sides at once, remove any audio # if we're showing both sides at once, remove any audio
# from the answer that's appeared on the question already # from the answer that's appeared on the question already
@ -224,7 +223,6 @@ class Previewer(QDialog):
audio = c.answer_av_tags() audio = c.answer_av_tags()
av_player.play_tags(audio) av_player.play_tags(audio)
else: else:
AnkiWebView.setPlaybackRequiresGesture(True)
av_player.clear_queue_and_maybe_interrupt() av_player.clear_queue_and_maybe_interrupt()
txt = self.mw.prepare_card_text_for_display(txt) txt = self.mw.prepare_card_text_for_display(txt)

View file

@ -526,14 +526,12 @@ class CardLayout(QDialog):
self.have_autoplayed = True self.have_autoplayed = True
if c.autoplay(): if c.autoplay():
AnkiWebView.setPlaybackRequiresGesture(False)
if self.pform.preview_front.isChecked(): if self.pform.preview_front.isChecked():
audio = c.question_av_tags() audio = c.question_av_tags()
else: else:
audio = c.answer_av_tags() audio = c.answer_av_tags()
av_player.play_tags(audio) av_player.play_tags(audio)
else: else:
AnkiWebView.setPlaybackRequiresGesture(True)
av_player.clear_queue_and_maybe_interrupt() av_player.clear_queue_and_maybe_interrupt()
self.updateCardNames() self.updateCardNames()

View file

@ -42,7 +42,6 @@ from aqt.sound import av_player, play_clicked_audio, record_audio
from aqt.theme import theme_manager from aqt.theme import theme_manager
from aqt.toolbar import BottomBar from aqt.toolbar import BottomBar
from aqt.utils import askUserDialog, downArrow, qtMenuShortcutWorkaround, tooltip, tr from aqt.utils import askUserDialog, downArrow, qtMenuShortcutWorkaround, tooltip, tr
from aqt.webview import AnkiWebView
class RefreshNeeded(Enum): class RefreshNeeded(Enum):
@ -315,12 +314,10 @@ class Reviewer:
q = c.question() q = c.question()
# play audio? # play audio?
if c.autoplay(): if c.autoplay():
AnkiWebView.setPlaybackRequiresGesture(False)
sounds = c.question_av_tags() sounds = c.question_av_tags()
gui_hooks.reviewer_will_play_question_sounds(c, sounds) gui_hooks.reviewer_will_play_question_sounds(c, sounds)
av_player.play_tags(sounds) av_player.play_tags(sounds)
else: else:
AnkiWebView.setPlaybackRequiresGesture(True)
av_player.clear_queue_and_maybe_interrupt() av_player.clear_queue_and_maybe_interrupt()
sounds = [] sounds = []
gui_hooks.reviewer_will_play_question_sounds(c, sounds) gui_hooks.reviewer_will_play_question_sounds(c, sounds)

View file

@ -361,12 +361,6 @@ class AnkiWebView(QWebEngineView):
newFactor = desiredScale / qtIntScale newFactor = desiredScale / qtIntScale
return max(1, newFactor) return max(1, newFactor)
@staticmethod
def setPlaybackRequiresGesture(value: bool) -> None:
QWebEngineSettings.globalSettings().setAttribute(
QWebEngineSettings.PlaybackRequiresUserGesture, value
)
def _getQtIntScale(self, screen: QWidget) -> int: def _getQtIntScale(self, screen: QWidget) -> int:
# try to detect if Qt has scaled the screen # try to detect if Qt has scaled the screen
# - qt will round the scale factor to a whole number, so a dpi of 125% = 1x, # - qt will round the scale factor to a whole number, so a dpi of 125% = 1x,