Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:46:33+00:00 2026-05-31T14:46:33+00:00

Like the title says, I need to load a video (.mp4) from the assets

  • 0

Like the title says, I need to load a video (.mp4) from the assets folder into a WebView.
I’ve tried a couple of things:

//First

String webpage = "<!doctype html><head><meta charset='utf-8'></head><body><video id='video' controls='controls' autoplay='autoplay' height=" + m.getHeight() + " width=" + m.getWidth() + "><source src='file:///android_asset/1003/landscape_1003_1_m864.mp4' /></video></body></html>";

wv.loadData(webpage, "text/html", "utf-8");

//Second

Load the same webpage but using the loadUrl() method

wv.loadUrl(webpage);

//Third

Loading the exact same webpage but with another method

wv.loadDataWithBaseURL("file:///android_asset/", webpage,"text/html", "utf-8", null);

I’ve tried to change the first parameter to null,also the webpage, …

Everything has to be added dynamically (the webview itself, the url to the video, the width, height, …) so making a XML file is not an option.

A lot of solutions I’ve found on the internet was to move the video to the Raw folder or SD card, but that is not an option (business decision).

It would be nice if somebody could help me.

P.S. If you could help me with the exact same thing but showing the video in a videoview with all the controls like a html5 video element (play, pause, seekbar, fullscreen) feel free!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:46:34+00:00Added an answer on May 31, 2026 at 2:46 pm

    I had the same issue. Unfortunately I didn’t find a solution. Instand of this I just do something like this:

    • Open the website in webview
    • When user opens the link which ends .mp4 I open new activity with video player.
    • Passing url
    • Open video

      public void onCreate(Bundle savedInstanceState) 
      {
      super.onCreate(savedInstanceState);
      
      parent = (TabLayout)this.getParent();
              setContentView(R.layout.XXXXXXXXXX);
              l = (ProgressBar)findViewById(R.id.webL);
              Resources res = getResources();
              mWebView = (WebView) findViewById(R.id.webview);
              mWebView.getSettings().setJavaScriptEnabled(true);                
              mWebView.getSettings().setPluginsEnabled(true);
              mWebView.getSettings().setSupportZoom(true);
              mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
              mWebView.loadUrl(res.getString(R.string.XXXXXX));   
              mWebView.getSettings().setAllowFileAccess(true);
              mWebView.setWebViewClient(new WebViewClient() 
              {
                  @Override
                  public void onPageFinished(WebView view, String url)  
                  {
                      super.onPageFinished(view, url);
                      l.setVisibility(View.INVISIBLE);                        
                  }
      
                  @Override
                  public void onPageStarted (WebView view, String url, Bitmap favicon)
                  {
                      super.onPageStarted(view, url, favicon);
                      l.setVisibility(View.VISIBLE);
                  }
      
                  @Override
                  public boolean shouldOverrideUrlLoading(WebView view, String url) 
                  {
                      if (url.endsWith(".mp4") )
                      {                           
                          data.url = url;
                          Intent intent = new Intent(getApplicationContext(), VideoPlayer.class);
                          startActivity(intent);
                          return true;
                      } 
                      else 
                      {
                          return super.shouldOverrideUrlLoading(view, url);
                      }
                  }
      
              });
      
      }
      

    ..and my video player:

    public class VideoPlayer extends Activity
    {
    private VideoView mVideoView;
    
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
    
        this.setContentView(R.layout.video);
        mVideoView = (VideoView) findViewById(R.id.surface_video); 
    
        mVideoView.setVideoURI(Uri.parse(data.url));
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();
        mVideoView.start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like the title says, I need a way to detect if the build is
So, just like the title says, I need to create an application that gets
Like the title says I need to write a function that will sort a
Like the title says, we need to set up WCF services between a .NET
As the title says,i need to mass-assign products to a category and from the
Like the title says, I just need something to migrate a set of tables
Like the title says, I need to use php (wordwrap or whatever works) to
well, as the title says, I need to create a component inheriting from the
Like the title says I need to have a final result where on one
Like the title says I'm having some trouble printing out symbol codes and their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.