在 Android 中使用 HTML5 在 WebView 中播放 MP4 影片


要在 WebView 中播放 MP4 影片,首先需要在清單中宣告內容提供程式 -

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

使用 open() 方法實現開啟檔案 -

URI myURL = URI.create("file:///mypath/new.mp4");
File f = new File(myURL);
ParcelFileDescriptor p =
   ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
return p;

更新於:25-06-02020

796 次瀏覽

開啟 職業生涯

完成課程後獲得認證

開始吧
廣告