• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Open file dialog from background script

    Opera add-ons
    2
    3
    1187
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nekomajin
      nekomajin last edited by

      I am in a need of some help.

      I am working on a music player extension. 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?

      Reply Quote 0
        1 Reply Last reply
      • gustavwiz
        gustavwiz last edited by

        Open the dialog in the script that you did it in before, and send a message to the background script with the file path.

        https://dev.opera.com/extensions/message-passing/
        https://developer.chrome.com/extensions/messaging

        Reply Quote 0
          1 Reply Last reply
        • nekomajin
          nekomajin last edited by

          That's not a solution to my problem.

          The createObjectURL() creates references to the files stored in the memory. It is useless to send these references to the background script, because when the panel unloads, the references cease to exist.

          Reply Quote 0
            1 Reply Last reply
          • First post
            Last post

          Computer browsers

          • Opera for Windows
          • Opera for Mac
          • Opera for Linux
          • Opera beta version
          • Opera USB

          Mobile browsers

          • Opera for Android
          • Opera Mini
          • Opera Touch
          • Opera for basic phones

          • Add-ons
          • Opera account
          • Wallpapers
          • Opera Ads

          • Help & support
          • Opera blogs
          • Opera forums
          • Dev.Opera

          • Security
          • Privacy
          • Cookies Policy
          • EULA
          • Terms of Service

          • About Opera
          • Press info
          • Jobs
          • Investors
          • Become a partner
          • Contact us

          Follow Opera

          • Opera - Facebook
          • Opera - Twitter
          • Opera - YouTube
          • Opera - LinkedIn
          • Opera - Instagram

          © Opera Software 1995-