2
2
let old = PIXI . VideoBaseTexture . fromUrl ;
3
3
PIXI . VideoBaseTexture . fromUrl = function fromUrl ( videoSrc , scaleMode , crossorigin , autoPlay ) {
4
4
if ( typeof videoSrc === "string" && videoSrc . startsWith ( "movies/" ) ) {
5
+ window . _logLine ( "YANFLY VIDEO " + videoSrc ) ;
5
6
let videoData = _vfs_resolve_file_sync ( videoSrc ) ;
6
7
let b = new Blob ( [ videoData ] , { type :"video/" + videoSrc . split ( "." ) [ videoSrc . split ( "." ) . length - 1 ] } ) ;
7
8
let objectURL = URL . createObjectURL ( b ) ;
8
9
let vidObj = old . call ( this , { src : objectURL , mime : "video/" + videoSrc . split ( "." ) [ videoSrc . split ( "." ) . length - 1 ] } , scaleMode , crossorigin , autoPlay ) ;
9
10
let a = setInterval ( function ( ) {
10
11
if ( vidObj . source . readyState === 4 && ( vidObj . source . buffered . end ( 0 ) >= vidObj . source . duration ) && vidObj . source . ended ) {
11
- window . _logLine ( "Revoking object url" ) ;
12
+ window . _logLine ( "YANFLY VIDEO Revoking object url" ) ;
12
13
URL . revokeObjectURL ( objectURL ) ;
13
14
clearInterval ( a ) ;
14
15
}
@@ -18,3 +19,31 @@ PIXI.VideoBaseTexture.fromUrl = function fromUrl(videoSrc, scaleMode, crossorigi
18
19
old . call ( this , ...arguments ) ;
19
20
}
20
21
} ;
22
+
23
+ let old_stock_playvideo = Graphics . _playVideo ;
24
+ let old_onvideoend = Graphics . _onVideoEnd ;
25
+ let ourl = Symbol ( "ObjectURL" ) ;
26
+ let hasRevoked = Symbol ( "hasRevoked" ) ;
27
+
28
+ Graphics . _playVideo = function ( src ) {
29
+ window . _logLine ( "MV VIDEO " + src ) ;
30
+ let videoData = _vfs_resolve_file_sync ( src ) ;
31
+ let b = new Blob ( [ videoData ] , { type :"video/" + src . split ( "." ) [ src . split ( "." ) . length - 1 ] } ) ;
32
+ if ( this [ ourl ] && ! this [ hasRevoked ] ) URL . revokeObjectURL ( this [ ourl ] ) ;
33
+
34
+ this [ ourl ] = URL . createObjectURL ( b ) ;
35
+ this [ hasRevoked ] = false ;
36
+
37
+ old_stock_playvideo . call ( this , this [ ourl ] ) ;
38
+ }
39
+
40
+ Graphics . _onVideoEnd = function ( ) {
41
+ if ( ! this [ hasRevoked ] ) {
42
+ URL . revokeObjectURL ( this [ ourl ] ) ;
43
+ this [ hasRevoked ] = true ;
44
+
45
+ window . _logLine ( "MV VIDEO END" ) ;
46
+ window . _logLine ( "Revoking object url" ) ;
47
+ }
48
+ old_onvideoend . call ( this ) ;
49
+ }
0 commit comments