@@ -3,6 +3,10 @@ import { localStorageService } from 'services';
33import { VideoStreamingSession } from 'app/drive/services/video-streaming.service/VideoStreamingSession' ;
44import { FormatFileViewerProps } from '../../FileViewer' ;
55
6+ const PROGRESS_INCREMENT = 0.2 ;
7+ const PROGRESS_INTERVAL_MS = 500 ;
8+ const MAX_SIMULATED_PROGRESS = 0.95 ;
9+
610const FileVideoViewer = ( {
711 file,
812 blob,
@@ -12,9 +16,42 @@ const FileVideoViewer = ({
1216} : FormatFileViewerProps ) : JSX . Element => {
1317 const videoRef = useRef < HTMLVideoElement > ( null ) ;
1418 const sessionRef = useRef < VideoStreamingSession | null > ( null ) ;
19+ const progressIntervalRef = useRef < NodeJS . Timeout | null > ( null ) ;
1520 const [ canPlay , setCanPlay ] = useState ( false ) ;
21+ const [ simulatedProgress , setSimulatedProgress ] = useState ( 0 ) ;
22+
23+ useEffect ( ( ) => {
24+ if ( disableVideoStream || canPlay ) return ;
25+
26+ progressIntervalRef . current = setInterval ( ( ) => {
27+ setSimulatedProgress ( ( prev ) => {
28+ const next = prev + PROGRESS_INCREMENT ;
29+ if ( next >= MAX_SIMULATED_PROGRESS ) {
30+ if ( progressIntervalRef . current ) {
31+ clearInterval ( progressIntervalRef . current ) ;
32+ progressIntervalRef . current = null ;
33+ }
34+ return MAX_SIMULATED_PROGRESS ;
35+ }
36+ return next ;
37+ } ) ;
38+ } , PROGRESS_INTERVAL_MS ) ;
39+
40+ return ( ) => {
41+ if ( progressIntervalRef . current ) {
42+ clearInterval ( progressIntervalRef . current ) ;
43+ progressIntervalRef . current = null ;
44+ }
45+ } ;
46+ } , [ disableVideoStream , canPlay ] ) ;
47+
48+ useEffect ( ( ) => {
49+ if ( ! disableVideoStream && ! canPlay && simulatedProgress > 0 ) {
50+ handlersForSpecialItems ?. handleUpdateProgress ( simulatedProgress ) ;
51+ }
52+ } , [ simulatedProgress , canPlay , disableVideoStream , handlersForSpecialItems ] ) ;
1653
17- // Handle shared items (blob-based playback)
54+ // Handle shared items
1855 useEffect ( ( ) => {
1956 if ( ! disableVideoStream || ! videoRef . current || ! blob ) return ;
2057
@@ -27,7 +64,7 @@ const FileVideoViewer = ({
2764 } ;
2865 } , [ disableVideoStream , blob ] ) ;
2966
30- // Handle streaming playback (non-shared items)
67+ // Handle streaming playback
3168 useEffect ( ( ) => {
3269 if ( disableVideoStream ) return ;
3370
@@ -50,9 +87,6 @@ const FileVideoViewer = ({
5087 credentials : file . credentials
5188 ? { user : file . credentials ?. user , pass : file . credentials ?. pass }
5289 : { user : bridgeUser , pass : userId } ,
53- onProgress : ( progress ) => {
54- handlersForSpecialItems ?. handleUpdateProgress ( progress ) ;
55- } ,
5690 } ) ;
5791
5892 sessionRef . current = session ;
@@ -118,6 +152,7 @@ const FileVideoViewer = ({
118152 ref = { videoRef }
119153 controls
120154 autoPlay
155+ preload = "metadata"
121156 style = { { width : '100%' , maxHeight : '80vh' , backgroundColor : '#000' } }
122157 className = { canPlay ? 'flex' : 'hidden' }
123158 >
0 commit comments