0

I want to play video inside my webview. I have examined different example but my HTML a bit different.

{\"mp4\":[{\"name\":\"240\",\"file\":\"http:\\\/\\\/xxxx.xxxx.net\\\/lt\\\/2016\\\/04\\\/24\\\/test_320x240.mp4\",\"type\":\"video\\\/mp4\"}

I can download HTML code and used function;

webview.loadData(myHTML,"text/html; charset=UTF-8", null);)

However, I can't display videos in my application. Thank you for helping.

deorez
  • 113
  • 1
  • 6

1 Answers1

0

You can try playing the video using VideoView rather than trying to load it in a webview.Below is the sample code:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    videoView = (VideoView) findViewById(R.id.videoView);
    File file = new File(Environment.getExternalStorageDirectory(), "rhyme.mp4");
    videoView.setVideoPath(file.getAbsolutePath());
    videoView.setMediaController(new MediaController(this));
    videoView.start();
}

Also if you want to stream some video files from internet, you can go ahead with ExoPlayer. Here is the link Kindly mark this reply as answer if it solves your problem.

Community
  • 1
  • 1
Saurabh7474
  • 450
  • 5
  • 12
  • Thanks but that not the solution that I expect. I've improve my solution a bit by using webview.loadDataWithBaseURL(). Now I can see videos in webview but I have problems about playing it. – deorez Apr 30 '17 at 18:22