1

I've had a working Google Chrome extension that was using Manifest v2 file where the "background" field was set as follows:

"background": {
    "page": "background.html"
  },

background.html was simple:

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
  <audio controls="" name="media" src="http://stream.from_somewhere.com:8000/now.mp3" id="myplayer"></audio>
</body>
</html>

However, Chrome extensions now require Manifest v3 with service_worker background parameter:

"background": {
    "service_worker": "background.js"
  },

How would I convert my existing background.html to background.js?

Danijel
  • 8,198
  • 18
  • 69
  • 133
  • AFAIK, even in manifest v2, there was nothing like `page` for a background script. It was always `scripts`. – Prerak Sola Feb 24 '23 at 11:44
  • 1
    Nope, there was "page". – Danijel Feb 24 '23 at 11:47
  • 1
    [chrome.offscreen](https://developer.chrome.com/docs/extensions/reference/offscreen/) might be what you need. – Thomas Mueller Feb 24 '23 at 12:01
  • Thomas, would you give a more detailed answer considering I'm a begginer in all things web or javascript related. – Danijel Feb 24 '23 at 12:06
  • 1
    I've never used chrome.offscreen to play audio, so if you want code to copy & paste into your extension, I can't help you. But you might want to read [Play audio from background script in chrome extention manifest v3 > New Solution With Offscreen Documents](https://stackoverflow.com/questions/67437180/play-audio-from-background-script-in-chrome-extention-manifest-v3/70402480#70402480) – Thomas Mueller Feb 24 '23 at 12:30

0 Answers0