@limrun/ui 0.4.0-rc.3 → 0.4.0-rc.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limrun/ui",
3
- "version": "0.4.0-rc.3",
3
+ "version": "0.4.0-rc.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,6 +27,10 @@
27
27
  background-color: black;
28
28
  }
29
29
 
30
+ .rc-video-loading {
31
+ aspect-ratio: 9 / 19.5;
32
+ }
33
+
30
34
  .rc-video-ios {
31
35
  top: 1.6%;
32
36
  left: 3.9%;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
1
+ import React, { useEffect, useRef, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
2
2
  import { clsx } from 'clsx';
3
3
  import './remote-control.css';
4
4
 
@@ -134,6 +134,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
134
134
  ({ className, url, token, sessionId: propSessionId, openUrl }: RemoteControlProps, ref) => {
135
135
  const videoRef = useRef<HTMLVideoElement>(null);
136
136
  const frameRef = useRef<HTMLImageElement>(null);
137
+ const [videoLoaded, setVideoLoaded] = useState(false);
137
138
  const wsRef = useRef<WebSocket | null>(null);
138
139
  const peerConnectionRef = useRef<RTCPeerConnection | null>(null);
139
140
  const dataChannelRef = useRef<RTCDataChannel | null>(null);
@@ -752,6 +753,9 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
752
753
  };
753
754
 
754
755
  useEffect(() => {
756
+ // Reset video loaded state when connection params change
757
+ setVideoLoaded(false);
758
+
755
759
  // Start connection when component mounts
756
760
  start();
757
761
 
@@ -932,7 +936,11 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
932
936
  />
933
937
  <video
934
938
  ref={videoRef}
935
- className={clsx('rc-video', platform === 'ios' ? 'rc-video-ios' : 'rc-video-android')}
939
+ className={clsx(
940
+ 'rc-video',
941
+ platform === 'ios' ? 'rc-video-ios' : 'rc-video-android',
942
+ !videoLoaded && 'rc-video-loading',
943
+ )}
936
944
  style={
937
945
  config.loadingLogo
938
946
  ? {
@@ -950,6 +958,7 @@ export const RemoteControl = forwardRef<RemoteControlHandle, RemoteControlProps>
950
958
  onKeyDown={handleKeyboard}
951
959
  onKeyUp={handleKeyboard}
952
960
  onClick={handleVideoClick}
961
+ onPlaying={() => setVideoLoaded(true)}
953
962
  onFocus={() => {
954
963
  if (videoRef.current) {
955
964
  videoRef.current.style.outline = 'none';