Playing MP4 video in WebView using HTML5 in Android

JavascriptWeb DevelopmentFront End Scripts

To play MP4 video in WebView, you need to first declare Content Provider in Manifest −

<provider android:name = "MyDataContentProvider" android:authorities="com.myapp" />

Implement open file with open() method −

URI myURL = URI.create("file:///mypath/new.mp4");
File f = new File(myURL);
ParcelFileDescriptor p =
   ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
return p;
raja
Updated on 25-Jun-2020 07:12:13

Advertisements