The discussion centers on a feature request from anon36895752 to prevent Discourse from unloading (cloaking) posts containing media players when a user scrolls. The user reported that when listening to SoundCloud mixes, scrolling down to read replies causes the player to unload, stopping the audio 1.
erlend_sh cautioned that while complete uncloaking is risky for performance, preventing specific posts from being offloaded is a viable direction. Falco suggested never offloading the Original Poster (OP), but anon36895752 rejected this as a hack, noting media can appear in any post. Alternatives like floating video players were dismissed as intrusive 6, 7.
Sam clarified that core Discourse is willing to implement logic to avoid cloaking posts with playing sound, but it requires specific integration with onebox APIs since generic DOM checks are insufficient. He noted that YouTube already avoids cloaking via its API 12 and suggested a similar approach for SoundCloud. The user discussed hiring for this feature, but Sam and codinghorror explained that the core team only works with Business Plan customers or accepts community patches, and no custom contracting is available for non-customers.
With Sam stating the feature is not currently high priority, the user remains open to community contributions or other solutions. A related plugin was recently suggested by elijah as a potential workaround.
A lot of posts on my forum are mixes. If the mix is posted at the top of the thread, and the user hits play, and then scrolls down the page to join the discussion and read the responses, eventually the player is unloaded, and this causes the mix to stop playing. Not ideal.
Is there a way to either specify how many posts before posts are unloaded, or remove this feature entirely?
Edit2: if this is not possible with stock discourse, I am open to hiring someone to program a discourse plugin that adds this feature. I have hired programmers from this forum in the past and always pay a fair rate, and pay deposit in advance, and final payment immediately upon completion.
Interesting use case. You definitely don’t want to stop Discourse from offloading any posts, as this is core functionality intended to prevent browser crashes and computers catching on and such.
But maybe it’d be possible to prevent a single post from being offloaded, while ditching the rest like normal.
Another possible way to solve this might be to prevent only the music player from being unloaded, conserving that stream somehow.
Honestly, i feel like this is a bit extreme. The way that system unloads posts is immediately when the go out of view. A browser can definitely handle having a bit of post history. I understand the need for cloaking with a really long thread, of 100s of posts, but I don’t see the need to begin cloaking after only 1 post has scrolled out of view.
As a plugin naturally, I find fb’s implementation pretty annoying too since it’s on all the time. But the only thing worse than having sound cut out when you scroll away from the player is having sound playing in your browser and not knowing where it’s coming from.
Well i’m not advocating for auto playing hidden audio, this is audio the user interaction requested to start playing. I’m only trying to avoid a sudden stop of this audio on scroll.
I agree with @codinghorror though, that floating video thing just seems like a bit much. It’s something i would expect to see on a really spammy news website. I would prefer if the post just stayed where it was, and simply did not cloak on scroll.
Is this something that could be accomplished with discourse’s plugin functionality? or would this involve some hacks to discourse core to accomplish it?
We are fine with core Discourse to have the smarts not to cloak posts with oneboxes that have currently playing sound.
Technically, there is no simple way to ask the DOM: “hi DOM is anything playing in element #t” so this means we need to be a specific change to various oneboxes to add this info so we could decide if to unload or not.
If you can get someone to build it cleanly we would be more than happy to consider the PRs required.
Yeah, now that i think about it, i don’t think you could ever know if a soundcloud player is playing, those are usually iframes, and therefore part of the shadow dom, and completely out of scope. But I think perhaps a suitable work around would be exposing an admin interface that had a bunch of settings like:
never cloak posts with youtube oneboxes
never cloak posts with soundcloud oneboxes
… etc
unless you are suggesting an alternative that is more elegant than this?
@gdpelican is this something i could hire you to build? I was quite happy with your work last time.
If wiring all the APIs is too hard I would be fine with a site setting of “don’t cloak posts with potentially playing media”, since the count is so low it probably makes no diff. Then all onebox needs to do is surface the fact that a onebox is “playable” by adding something like a playable class to the element.
Very good point, i overlooked the fact that discourse uses the HTML5 widget and not the iframe player for soundcloud. This is definitely the more correct solution, and i think with these types of things it is best to take the most accurate approach. My main focus here is with the soundcloud onebox, but perhaps it will lay the groundwork to have other one boxes added along the way in the future.
I appreciate the offer, but that forum does not make anywhere near that kind of money in a year, so it is simply not realistic for me to make that kind of decision, unfortunately.
Thats the problem with ruby. php devs are a dime a dozen. i’m sure there’s plenty on my forum. But ruby? ruby devs are like a rare gem. Infact i’m personally a developer full time, i work mostly with python and javascript. I’ve dabbled a bit with ruby, but i’m no where near good enough to consider submitted a PR. If i did i think it would be best described as a steaming pile of monkey and immediately rejected.