I'm developing an app that installs files ( index.html, style.css ... ) to SD-card of phone for web server
The web server needs to get mp3 files to play.
My problem is what I couldn't find where is my mp3 file??
For example..
It works fine If i put mp3 file in same folder of index.html.
<a href="somthing.mp3"
data-format="mp3 ogg">mp3 file</a>
However, I couldn't get the route of mp3 if I put higher folder than the folder of index.html..
I tried
<a href="/sdcard/MUSIC/somthing.mp3"
data-format="mp3 ogg">mp3 file</a>
and
<a href="http://xxx.xxx.xxx.xxx:8080/sdcard/MUSIC/somthing.mp3"
data-format="mp3 ogg">mp3 file</a>
"http://xxx.xxx.xxx.xxx/index.html" is my android web server ...
How can I get my file???
Related
I have a simple image in my html which renders fine on my PC, but not on my smartphone:
<div id="welcomebox">
<img src="geschenk.jpg"/>
</div>
my folder-structure is as follows:
C:/Maus
- index.html
- geschenk.jpg
on my smartphone I copy that folder to my download-folder and open index.html from there. There's no web-server included, I directly open the file from the filesystem.
But on my smartphone the image isn't displayed.
Chrome will receive a content scheme from the Files app like:
content://com.google.android.apps.nbu.files.provider/1/file:// ...../index.html
As soon as Chrome 'sees' a content scheme it cannot display pictures as even if Chrome changes the scheme to:
content://com.google.android.apps.nbu.files.provider/1/file:// ...../geschenk.jpg
the provider will not let it access as there is no read permission for it.
The Android filesystem structure can't open relative file paths the same way other systems do.
So the answer is you need to use a complete hardcoded file:/// path.
This is not a very good approach since you need to replace all the URLs/paths in your HTML files.
Another approach if you are determined to do so, you can upload all project resources such as images, CSS, javascript to the cloud, like using SDN to access those files and to let the project work. But using the SDN approach it's easier to upload everything including the HTML files to a hosting account.
I'm trying to view my HTML file on the android mobile browser.
My HTML file has the following code:
<html>
<head>
<title>Testy</title>
</head>
<body>
<h1>Captain is Here</h1>
<img src='captain.jpg' width='30%' alt='Testy'/>
</body>
</html>
The image(captain.jpg) is also in the same folder where the HTML page is located. I'm getting the image on the computer browser but when I'm trying to open it in mobile browser image, not showing. I tried giving different file paths. How can I achieve this by giving a universal path by that a mobile that containing these HTML files should open in respective browsers and render images too?
1- your image size is too large try an image with a smaller size or resize or format your image into a smaller size.
try src-'./caption.jpg' instead of src='caption.jpg'
Opening through directry location of Html in Chrome Solve this.
For that get html file location directry in details by file manager
Example storage/emulated/0/web_folder/file.html and copy it
After that
1.Open chrome
2.type file:/// and Paste directry location
3."file:///storage/emulated/0/web_folder/file.html" Now it can run with image
Ensure that storage permission allowed to chrome
For that Open permission settings for chrome and allow storage permission
that's where mhtml and URLs get used!!!
Have you ever downloaded a page using chrome in android? if so you would have known about mhtml
MHTML, an initialism of "MIME encapsulation of aggregate HTML documents", is a web page archive format used to combine, in a single computer file, the HTML code and its companion resources (such as images, Flash animations, Java applets, and audio and video files) that are represented by external hyperlinks in the web page's HTML code
to convert your html to mhtml you may use some tools but you can also do it manually .
converting need not rename the file as index.mhtml but use all necessary files as hyperlinks
you may use image hosting sites like imgur or imgbb or even firebase if your familiar.
after you host get the link by
right-clicking image
open image in new tab
copy link
use it(link) instead of captain.jpg
Here is an example of how to get link using imgbb
We have Android device. Inside that device, on internal flash is located Download folder and inside that folder resides cat.mp4
Currently we are using following script:
<video width="365" height="200" autoplay loop controls autobuffer>
<source src="file:///sdcard/Download/cat.mp4" type='video/mp4'>
</video>
We have also tried following script:
<video width="365" height="200" src="file:///sdcard/Download/cat.mp4" autoplay loop controls autobuffer>
</video>
Both scripts do not play local video file.
The html file itself, which contains above video tags, comes from certain remote location (not local).
(If we place cat.mp4 on remote location it plays without any problem)
Is this correct approach to play local mp4 files in WebView?
If not, which part of the code is incorrect?
Is this correct approach to play local mp4 files in WebView?
Nope you can't do that in general (webView or not). Security measures (in HTML protocols) do not allow a web-based application to access a user's files from their hard drive (or other storage).
The user must allow access by selecting the file themselves (hence the browse/select file option in some websites). Only options are:
Put HTML and video files online (load everything from web)
Put HTML in SD card's download folder then you can use src="cat.mp4"
A side issue with your approach begs the question, what happens for site visitors without these files on SD card? Or worse a user not even using Android (on a Win PC how can my browser make sense of src="file:///sdcard/Download/cat.mp4" ?)
I am trying to have an epub file link to an html document that is stored locally on my device.
I have an <a> tag with the href being:
"file://sdcard/mobi/content/file.html".
This does not work.
The epub file is currently located in the mobi directory as shown above, is there a way to relatively access the html file or is my href wrong?
I have tested the reader and it can open the file.html page if it is hosted on our local network.
Thank you in advance for any help
I have a script that pulls an image from SQL Server and displays it as a link or on a page. Works perfectly in a browser and on most mobile devices. However, when linking directly to the aspx file link Android phones download the content but don't recognize the extension as an image, so they just save in the downloaded items folder as an image with an .aspx extension.
How can I cause Android devices to recognize the fileStream as an image instead of an object to be downloaded?
Thanks
I just tested a simple HTML file in the browser:
<!DOCTYPE html>
<html>
<body>
This is a test!<br/>
link
</body>
</html>
When I click on the link, the image is displayed in the browser (not downloaded).
The problem must be that imagehandler.aspx is not sending an appropriate set of headers. Maybe the script is not setting a Content-Type header, or the wrong value, or it is sending Content-Disposition attachment.
EDIT: This is what the browser app is getting: