简体   繁体   中英

Using javascript functions from html file in android

I have a javascript (inside of an html file) to load and reproduce the videos by streaming in my android app, so I am trying to use a webview to display the video. My problem is that the file is not in a server, but it is a project resource (I mean it is in the project directory, exactly in /res/raw/video_player.html ) and I want to call a specific function of the javascript passing the video url as param.

Does anyone have an idea about how to do this?

Thanks in advance.

If I understand correctly you wish to set the src attribute of your video tag. See this answer for how to do that from JavaScript.

To play video in full-screen mode the WebView passes the URL to the Android media player and the file:///android_asset scheme is something only the WebView supports. If you're assigning an http(s) URL then you're fine and don't need to do anything else, otherwise I guess one way would be to unpack the video to your data folder and use a 'regular' file:// URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM