Question

I have been having some issues with my code to play html5 vide. I created a short presentation in powerpoint and exported it html5, it contain a video, I have copy the exported files into my assets files in android buy my video is not playing.

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebChromeClient;
import android.webkit.WebViewClient;


public class WebViewActivity7 extends Activity {

private WebView webView7;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview7);

    webView7 = (WebView) findViewById(R.id.webView8);
    webView7.getSettings().setJavaScriptEnabled(true);
    webView7.getSettings().setAllowFileAccess(true);
    webView7.getSettings().setPluginsEnabled(true);
    webView7.getSettings().setAllowFileAccess(true);
    webView7.setWebChromeClient(new WebChromeClient());
    webView7.setWebViewClient(new WebViewClient());
    webView7.getSettings().setBuiltInZoomControls(true);
    webView7.loadUrl(url);

}
   String url ="file:///android_asset/HTML5.html";
   }

Everything else on my presentation works like a charm except the video, it does not play and i get the following error, when I tabbed on the video to play it on the scree on my android tablet - Android 4.0:

MediaPlayer Error (1, -2147483648)

I have been trying to get a solution to my problem for the last 5 days, I have read quite a few forums, change my code several times and nothing.

I found on a post that the reasons for the above error are:

  1. File path is in error. Incorrect directory or Url or Uri found.
  2. Media file is in error, incompatible format.
  3. Missing permissions.

I have checked all the above on my app and still can't find how to solve it.

Everything else on my html5 file and folder works fine, so i don't think is a directory problem. My embedded video files are .mp4 and .webm sand there are supposed to be supported. I look at the permission of my files and folder and all seems to be fine. I have an iPad version of my app working fine with the same html5 files and folder and the videos work fine.

Anyone have any idea how can I fix this problem, coding is supposed to be fun but after 5 days on this problems i am having second thoughts.

Thank you. DPP

Addition to above:

I found in another forum that android does not allow to play video files larger than 1MB, Is this true? One of my videos is 3.2 MB and the other one is 29MB.

Answer: the data about the video size is not true per what I have observed. I have set up my videos (Video files MP4 only with not HTML5 code) to play from the "res/raw" folder and it is all good. I just can't get them to play from the assets folder embedded on HTML5.

Still looking around for solutions, but having my videos on the "res/raw" folder it is a good alternative to my problem.

DPP

Was it helpful?

Solution

I have solved this problem by using copyAssets into sd card and running the index.HTML from the sdcard. see post Running an html5 site withing android app

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top