Changeset fe680aa in Klonkt


Ignore:
Timestamp:
07/01/2026 01:25:49 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
1bc0886
Parents:
131e266
Message:

feat(news): short feed videos (gif/cover loops) autoplay + loop muted

A federated animated cover / short clip renders in the News feed as a
<video controls>. On loadedmetadata, videos <=30s now drop their controls and
autoplay + loop muted like a GIF (matching the cover behaviour); longer real
videos keep their controls. Duration-based so it works for any fediverse source.

  • src/views/pages/news.ejs — per-.tl-media-video loadedmetadata gif-mode wiring

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/news.ejs

    r131e266 rfe680aa  
    265265})();
    266266
     267/* Short feed videos (gif/cover loops like an animated cover) autoplay + loop muted like a GIF;
     268   longer real videos keep their controls. Decided on the actual duration once metadata loads. */
     269(function(){
     270  document.querySelectorAll('.tl-media-video').forEach(function(v){
     271    if (v.dataset.gifWired) return; v.dataset.gifWired = '1';
     272    var decide = function(){
     273      if (v.duration && v.duration <= 30) {
     274        v.removeAttribute('controls'); v.loop = true; v.muted = true; v.play().catch(function(){});
     275      }
     276    };
     277    if (v.readyState >= 1) decide(); else v.addEventListener('loadedmetadata', decide, { once: true });
     278  });
     279})();
     280
    267281/* Like/Boost toggle in place — POST via fetch, flip the button, stay on the page (no reload, no banner). */
    268282(function(){
Note: See TracChangeset for help on using the changeset viewer.