0

now my webapp works like this : users click the button, then app will post a url to get video from internet.

my purpose is: when sdcard have the video that users want to see, app will not ask the internet but play the local video.

then with crosswalk(this is a very good frame), I find the method "shouldInterceptLoadRequest",i can do something when i use the method to get every url that app prepare to send.

but after my handle, i need to return a XWalkWebResourceResponse by using createXWalkWebResourceResponse(String mimeType, String encoding, InputStream data).

however here come the question code:

InputStream inputStream = new FileInputStream(filePath);
return createXWalkWebResourceResponse("video/*","UTF-8",inputStream);

this code does not work, and the player still get the internet video rather than local video.

i am wonder where i am wrong? i am sure that read/write premission is all set and the filepath is real(i make a mediaplayer demo to play the mp4file and succeed).

i try to read the input stream by getData(),and also succeed, that means the xwalkwebresourceresponse has data, but why the data does not work?

please someone that know where i am wrong could tell me which place is wrong.i have search the document, website and any place i can search but still can not find how to solve it.

Sample
  • 49
  • 5

1 Answers1

0

i am the questioner. i did not find the key to answer.but i find some other ways to solve the problem.

when i need to use 'shouldInterceptLoadRequest' to replace the webresource with localresource. i can also set up a webserver to make the localresource becoming webresource. that means the localresource can be reachable by web. so i dont need to use 'shouldInterceptLoadRequest'.

i make the web videos path changed by js, and when the App load the js, i use 'shouldInterceptLoadRequest' to replace the web js with local js. local js can change the web video path. after that i set up a webserver to provide the localresources path, so the app can load the localresouce now.

however i still not know why 'shouldInterceptLoadRequest' can not replace the web video. wish someone can answer me.

(oh, i set up webserver with AndroidAsync, AndroidAsync can be searched by github)

poor english. wish can help you.

Sample
  • 49
  • 5