interledger / web-monetization-projects

Coil projects that use Web Monetization. Primarily Coil's browser extension and related WM polyfills.
web-monetization-projects-coilhq.vercel.app
Apache License 2.0
81 stars 17 forks source link

Background Web Monetization #387

Open sharafian opened 4 years ago

sharafian commented 4 years ago

Right now you can enable background web monetization for a page via the hidden developer options.

It would be nice, for sites that do things like audio streaming, to have a way for normal users to enable background WM.

I think the first iteration of this feature would be a button in the extension that lets you enable background WM on a page, along with an indicator in the tab bar to show which pages are monetizing in the background (could use favicon, title, or anything else we have at our disposal). We may also want a whitelist of sites for which background WM is always allowed under certain conditions (when audio/video is playing, for instance).

For the long term we'll basically have multiple criteria that determine when a site can monetize in the background. For instance, we may want to have a prompt to enable background monetization, which would come up on sites when user interaction triggers audio/video to start. Basically it'd be a decision tree similar to the kind that a browser would use to decide if a site can open a popup or not.

CC @fruehle for design input on what this could look like

It'd be cool to have the first iteration in the fairly near term but it's lower priority than iframe monetization

sublimator commented 4 years ago

An example of a webext which can change the favicon of tabs, using canvas to render emojis https://github.com/ivebencrazy/favioli

sublimator commented 4 years ago

https://github.com/interledger/webmonetization.org/issues/17

drsm79 commented 3 years ago

+1 for this - I was about to open a new issue, with "A fairly common use case is to have music playing on one tab in the background while doing something else in a different tab in the foreground. Currently this means WM streams will stop for the page playing audio, which limits the applicability of WM to audio content (e.g. what we're building at audiotarky.com, for grant for the web). Would it be possible & reasonable to have payments continue if audio is playing? The alternatives are either poor UX (stop playing when the stream stops) or not good for the content provider (don't get paid)."

tribeofnoise commented 3 years ago

Hi Ben, Chris told me off-tab music monetization is on Coil's road map. Wonderful. Free Music Archive has several reasons to be super happy to embed this feature :-) How can we help?

kookster commented 2 years ago

Hi Ben, I'm working on podcast support for WM, much as @dellagustin was a couple years back. Curious if there has been any progress on the background issue? Would be great if there was a way for our podcast player to continue to stream payments while audio was playing, even in the background.

kookster commented 2 years ago

@sharafian as per the comment above, is there someplace to see what coil might have had on their roadmap for audio/music support?

kookster commented 2 years ago

idk who does what coilhq; perhaps @sublimator you might also have insight into the roadmap/possibility of this?

kookster commented 1 year ago

Hey folks, any update on this as a possible enhancement/roadmap item?

sublimator commented 1 year ago

I believe it's on the list to investigate, but currently transitioning the extension to MV3 and and work on WM2 (https://github.com/WICG/webmonetization/pull/193) is higher priority.

sublimator commented 1 year ago

@kookster

iirc, one proposed solution was to somehow track the playing state of audio/video elements and allow backgrounded streaming if some media was playing

AlexLakatos commented 1 year ago

I think that's OK, but if we build this we also need to plug into the tabs API and add a "Pause Monetization" option, and possibly tie that into the "Mute Tab" state as well.

sublimator commented 1 year ago

@AlexLakatos

A long time ago (xmas of 2019) I added some hidden controls that allowed manual pause/resume and allowed "pinning" a tab so that it would keep monetizing when it had lost focus.

What do you mean by "tabs API" ?

tribeofnoise commented 1 year ago

Wow! Over 2 years ago when we started asking for this. Time flies. Life is about priorities so I hope it ever makes it to someone's top prio list ;-)

AlexLakatos commented 1 year ago

I meant https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs in order to get muted info, and https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/ContextType in order to add a new menu item on the tabs popup menu that allows you to pause monetization for a tab.

sublimator commented 1 year ago

What does "muted" mean there?

AlexLakatos commented 1 year ago
Screenshot 2022-08-24 at 16 15 44

You can mute tabs, and that mutes all audio coming from them. That would mean that while a tab is muted, it won't be web monetized. Similarly, you should be able to choose to "Pause Monetization" from that tab menu.

sublimator commented 1 year ago
image

So we used to have hidden controls, with the left button being a toggle for play/pause and the right button a toggle for streaming while backgrounded or paused (as normal)

I am not sure if I am remembering correctly, but there was some resistance to (automatic) background web monetization, mainly due to the potential for abuse. If it was possible to declare via some tag that you wanted streaming to continue while backgrounded, then the thought was that everyone wants more money, so everyone would just do that.

It wouldn't be very convenient (nor inline with the philosophy of having an autonomous user agent) if one had to manually put a page into background streaming mode. Perhaps the setting could be remembered for a particular domain?

I think it was PPK who proposed detecting audio playing, but couldn't that be abused by simply playing an empty sound on a loop?

WM as originally intended/envisioned was supposed to be a very simple "ambient" streaming.

sublimator commented 1 year ago

For future reference, should also consider how disabling site/page/payment pointer would would fit in with this feature. Some experiments @ https://github.com/coilhq/web-monetization-projects/pull/1216