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
Published on 06-Apr-2018 08:20:15
Advertisements