@@ -67,61 +67,50 @@ export const video = (() => {
6767 const bar = document . getElementById ( 'progress-bar-video-love-stroy' ) ;
6868 const inf = document . getElementById ( 'progress-info-video-love-stroy' ) ;
6969
70- return request ( HTTP_GET , src )
71- . withCancel ( new Promise ( ( re ) => vid . addEventListener ( 'undangan.video.prefetch' , re , { once : true } ) ) )
72- . default ( { 'Range' : 'bytes=0-1' } )
73- . then ( ( res ) => {
74- vid . dispatchEvent ( new Event ( 'undangan.video.prefetch' ) ) ;
70+ return request ( HTTP_GET , src ) . withNoBody ( ) . default ( { 'Range' : 'bytes=0-1' } ) . then ( ( res ) => {
7571
76- if ( res . status === HTTP_STATUS_OK ) {
77- vid . preload = 'none' ;
78- vid . src = util . escapeHtml ( src ) ;
79- wrap . appendChild ( vid ) ;
72+ if ( res . status === HTTP_STATUS_OK ) {
73+ vid . preload = 'none' ;
74+ vid . src = util . escapeHtml ( src ) ;
75+ wrap . appendChild ( vid ) ;
8076
81- return Promise . resolve ( ) ;
82- }
77+ return Promise . resolve ( ) ;
78+ }
8379
84- if ( res . status !== HTTP_STATUS_PARTIAL_CONTENT ) {
85- throw new Error ( 'failed to fetch video' ) ;
86- }
80+ if ( res . status !== HTTP_STATUS_PARTIAL_CONTENT ) {
81+ throw new Error ( 'failed to fetch video' ) ;
82+ }
8783
88- const loaded = new Promise ( ( r ) => vid . addEventListener ( 'loadedmetadata' , r , { once : true } ) ) ;
84+ const loaded = new Promise ( ( r ) => vid . addEventListener ( 'loadedmetadata' , r , { once : true } ) ) ;
8985
90- vid . src = util . escapeHtml ( src ) ;
91- wrap . appendChild ( vid ) ;
86+ vid . src = util . escapeHtml ( src ) ;
87+ wrap . appendChild ( vid ) ;
88+
89+ return loaded ;
90+ } ) . then ( ( ) => {
91+ vid . pause ( ) ;
92+ progress . complete ( 'video' ) ;
93+
94+ return request ( HTTP_GET , src ) . withRetry ( ) . withProgressFunc ( ( a , b ) => {
95+ const result = Number ( ( a / b ) * 100 ) . toFixed ( 0 ) + '%' ;
96+
97+ bar . style . width = result ;
98+ inf . innerText = result ;
99+ } ) . default ( ) . then ( resToVideo ) ;
100+ } ) . then ( ( res ) => {
101+ vid . controls = true ;
102+ vid . disableRemotePlayback = true ;
103+ vid . disablePictureInPicture = true ;
104+ vid . controlsList = 'noremoteplayback nodownload noplaybackrate' ;
92105
93- return loaded ;
94- } )
95- . then ( ( ) => {
96- vid . pause ( ) ;
97- progress . complete ( 'video' ) ;
98-
99- return request ( HTTP_GET , src )
100- . withProgressFunc ( ( a , b ) => {
101- const result = Number ( ( a / b ) * 100 ) . toFixed ( 0 ) + '%' ;
102-
103- bar . style . width = result ;
104- inf . innerText = result ;
105- } )
106- . withRetry ( )
107- . default ( )
108- . then ( resToVideo )
109- . then ( ( v ) => {
110- vid . controls = true ;
111- vid . disableRemotePlayback = true ;
112- vid . disablePictureInPicture = true ;
113- vid . controlsList = 'noremoteplayback nodownload noplaybackrate' ;
114-
115- vid . load ( ) ;
116- observer . observe ( vid ) ;
117- return v ;
118- } )
119- . catch ( ( err ) => {
120- bar . style . backgroundColor = 'red' ;
121- inf . innerText = `Error loading video` ;
122- console . error ( err ) ;
123- } ) ;
124- } ) ;
106+ vid . load ( ) ;
107+ observer . observe ( vid ) ;
108+ return res ;
109+ } ) . catch ( ( err ) => {
110+ bar . style . backgroundColor = 'red' ;
111+ inf . innerText = `Error loading video` ;
112+ console . error ( err ) ;
113+ } ) ;
125114 } ;
126115
127116 if ( ! window . isSecureContext ) {
0 commit comments