I am working on a music player extension for Opera browser. The idea is simple: select files from the local machine and play them in the sidebar. Thanks to the <audio>
element, everything is working fine, while the sidebar panel is open.
I use the createObjectURL()
method to pass the files to the <audio>
element. The problem is that it only holds a reference to the files in the memory, which gets lost when the sidebar panel unloads. I can send these references to the background script, but it won't help.
Using a FileReader
is not an option, because it uses a lot of CPU and RAM, and temporarily freezes the browser when I open the files. So I came up with the idea to use the createObjectURL()
method in the background script, so the references would be alive while the browser itself is running.
Now the problem is that I can't open a file dialog from the background script. I can create a file type input, and also use the click()
method, but the dialog window does not show up. However, the click event happens, because the onclick
event listener is being called.
So I'd like to ask some help. Is it possible to open the file dialog from the background script at all? If it is, how can I make it work?