@streamscloud/kit 0.2.27-1775564173889 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,15 +25,6 @@ $effect(() => {
25
25
  }
26
26
  });
27
27
  });
28
- // Eagerly load video on mount when no poster — show first frame immediately
29
- $effect(() => {
30
- if (!poster && video && !video.src) {
31
- untrack(() => {
32
- video.src = src;
33
- video.load();
34
- });
35
- }
36
- });
37
28
  // Register player instance in global playback manager
38
29
  $effect(() => untrack(() => {
39
30
  PlaybackManager.registerMountedPlayer(id, {
@@ -81,19 +72,24 @@ $effect(() => {
81
72
  }
82
73
  const [entry] = entries;
83
74
  latestEntry = entry;
84
- if ((entry.isIntersecting || allowPreloading) && !video.src) {
75
+ if ((entry.isIntersecting || allowPreloading || !poster) && !video.src) {
85
76
  video.src = src;
86
77
  video.load();
87
- if (autoplayState === true) {
88
- const handleCanPlay = () => {
89
- if (latestEntry?.isIntersecting) {
90
- void play();
91
- autoplayState = false;
92
- }
93
- };
94
- video.addEventListener('canplay', handleCanPlay, { once: true });
95
- return;
78
+ }
79
+ if (autoplayState === true && entry.isIntersecting) {
80
+ const attemptPlay = () => {
81
+ if (autoplayState === true && latestEntry?.isIntersecting) {
82
+ void play();
83
+ autoplayState = false;
84
+ }
85
+ };
86
+ if (video.readyState >= 3) {
87
+ attemptPlay();
96
88
  }
89
+ else {
90
+ video.addEventListener('canplay', attemptPlay, { once: true });
91
+ }
92
+ return;
97
93
  }
98
94
  if (autoplayState !== 'on-appearance') {
99
95
  return;
@@ -120,7 +116,7 @@ $effect(() => {
120
116
  }
121
117
  }, {
122
118
  root: intersectionContainer,
123
- rootMargin: poster ? '0px' : '200px',
119
+ rootMargin: '0px',
124
120
  threshold: [0.1, 0.4, 0.6]
125
121
  });
126
122
  observer.observe(container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.2.27-1775564173889",
3
+ "version": "0.2.28",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",