前提・実現したいこと
ブラウザゲームに使うためのオリジナルブラウザを制作したい。現在PyQt5を使用して制作している。
発生している問題・エラーメッセージ
このページを開こうとすると
js: Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened. js: Uncaught EncodingError: Unable to decode audio data js: Uncaught (in promise) EncodingError: Unable to decode audio data js: The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
というようなエラーが発生する
該当のソースコード
python
1import sys 2from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication, QWidget, QLabel, QLineEdit, QGridLayout, QPushButton, QDesktopWidget, qApp, QMenu 3from PyQt5.QtGui import QIcon 4from PyQt5.QtCore import QUrl 5from PyQt5.QtWebEngineWidgets import QWebEngineView 6 7class ShinyBrowserWindow(QMainWindow): 8 9 def __init__(self): 10 super().__init__() 11 12 self.initUI() 13 14 15 def initUI(self): 16 17 menubar = self.menuBar() 18 fileMenu = menubar.addMenu('メニュー') 19 20 impMenu = QMenu('アクション', self) 21 impAct1 = QAction('メイン画面へ', self) 22 impMenu.addAction(impAct1) 23 impAct2 = QAction('フェス画面へ', self) 24 impMenu.addAction(impAct2) 25 impAct3 = QAction('新規登録', self) 26 impMenu.addAction(impAct3) 27 28 fileMenu.addMenu(impMenu) 29 30 textEdit = QTextEdit() 31 self.setCentralWidget(textEdit) 32 33 backAct = QAction(QIcon("back.png"), '戻る', self) 34 backAct.setShortcut('Ctrl+Z') 35 backAct.setStatusTip('ページを戻します') 36 backAct.triggered.connect(self.back) 37 38 nextAct = QAction(QIcon("next.png"), '進む', self) 39 nextAct.setShortcut('Ctrl+X') 40 nextAct.setStatusTip('ページを進めます') 41 nextAct.triggered.connect(self.next) 42 43 refreshAct = QAction(QIcon("refresh.png"), '更新', self) 44 refreshAct.setShortcut('F5') 45 refreshAct.setStatusTip('ページを更新します') 46 refreshAct.triggered.connect(self.reload) 47 48 exitAct = QAction(QIcon("refresh.png"), '閉じる', self) 49 exitAct.setShortcut('Ctrl+Alt+Del') 50 exitAct.setStatusTip('ページを閉じます') 51 exitAct.triggered.connect(self.close) 52 53 self.statusBar() 54 55 fileMenu.addAction(backAct) 56 fileMenu.addAction(nextAct) 57 fileMenu.addAction(exitAct) 58 59 toolbar = self.addToolBar('Exit') 60 toolbar.addAction(backAct) 61 toolbar.addAction(nextAct) 62 toolbar.addAction(refreshAct) 63 64 initurl = 'https://shinycolors.enza.fun/' 65 self.browser = QWebEngineView() 66 self.browser.load(QUrl(initurl)) 67 self.setCentralWidget(self.browser) 68 self.setGeometry(200, 200, 1280, 720) 69 self.setWindowTitle('ShinyBrowser') 70 self.show() 71 72 self.url = QLineEdit() 73 74 def back(self): #def3つはまだちゃんとできていない 75 url = QUrl(self.url.text()) 76 self.browser.load(url) 77 self.updateCurrentUrl 78 79 def next(self): 80 url = QUrl(self.url.text()) 81 self.browser.load(url) 82 self.updateCurrentUrl 83 84 def reload(self): 85 url = QUrl(self.url.text()) 86 self.browser.load(url) 87 self.updateCurrentUrl 88 89if __name__ == '__main__': 90 91 app = QApplication(sys.argv) 92 93 94 ex = ShinyBrowserWindow() 95 sys.exit(app.exec_())
試したこと
色々なサイトを見ましたが、どうも自作ブラウザにデコードをさせる機能をのせているようなものが見当たらない...
補足情報(FW/ツールのバージョンなど)
実行環境
Windows 10
Python 3.7.3
PyQt5 ver4.2.8(だったはず、最新verのやつです)
あなたの回答
tips
プレビュー