@@ -111,7 +111,7 @@ var LibraryHTML5Video = {
111111 } ,
112112
113113 html5video_player_load__deps : [ '$GL' ] ,
114- html5video_player_load : function ( player_id , src ) {
114+ html5video_player_load_url : function ( player_id , src ) {
115115 VIDEO . player [ player_id ] . src = UTF8ToString ( src ) ;
116116 var texId = GL . getNewId ( GL . textures ) ;
117117 var texture = GLctx . createTexture ( ) ;
@@ -125,6 +125,40 @@ var LibraryHTML5Video = {
125125 VIDEO . player [ player_id ] . textureId = texId ;
126126 } ,
127127
128+ html5video_player_load : function ( player_id , src ) {
129+
130+ try {
131+ var filePath = UTF8ToString ( src ) ; // The path to your file in MEMFS
132+ var data = FS . readFile ( filePath , { encoding : 'binary' } ) ;
133+ var ext = filePath . split ( '.' ) . pop ( ) ;
134+
135+ var stats = FS . stat ( filePath )
136+ var fileSizeInBytes = stats . size ;
137+
138+ const blob = new Blob ( [ data ] , { type : 'video/' + ext } ) ;
139+ const videoSrc = URL . createObjectURL ( blob ) ;
140+
141+ VIDEO . player [ player_id ] . src = videoSrc ;
142+ var texId = GL . getNewId ( GL . textures ) ;
143+ var texture = GLctx . createTexture ( ) ;
144+ texture . name = texId ;
145+ GL . textures [ texId ] = texture ;
146+ GLctx . bindTexture ( GLctx . TEXTURE_2D , texture ) ;
147+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_MAG_FILTER , GLctx . LINEAR ) ;
148+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_MIN_FILTER , GLctx . LINEAR ) ;
149+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_WRAP_S , GLctx . CLAMP_TO_EDGE ) ;
150+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_WRAP_T , GLctx . CLAMP_TO_EDGE ) ;
151+ VIDEO . player [ player_id ] . textureId = texId ;
152+
153+ // Check the file size
154+ //console.log('File size:' + fileSizeInBytes);
155+ //console.log('data size:' + data.length);
156+ } catch ( error ) {
157+ console . error ( 'Error reading file:' + filePath + " " + error ) ;
158+ }
159+ } ,
160+
161+
128162 html5video_player_pixel_format : function ( player_id ) {
129163 var string = VIDEO . player [ player_id ] . pixelFormat ;
130164 var size = lengthBytesUTF8 ( string ) + 1 ;
0 commit comments