2013-04-30 81 views
1

我有一個視頻元素:的Android無法打開文件

<video><source src="path/video.webm" type="video/webm"></video> 

這起在Firefox和Chrome沒有任何問題。然而,當我在Android上運行(模擬器4.1)不和的logcat表明我這個錯誤:

Failed to open file '/android_asset/www/path/video.webm'. (No such file or directory)

視頻被包括在路徑assets/www/path/video.webm,這應該是正確的下APK。

這裏有什麼問題?

+0

你是如何加載你的WebView? – 323go 2013-04-30 14:23:02

+0

@ 323go我使用默認的Cordova 2.6項目模板,沒有任何修改。 – jgillich 2013-04-30 14:29:00

回答

3

問題是,科爾多瓦不支持存儲在應用程序內的視頻或音頻文件。解決方案是將文件複製到內部存儲並從那裏打開。

CB-6079報價:

The assets directory is an alias to the APK. An APK is like a JAR file, it's a special type of ZIP file that has the application's classes in it, as well as its resources and assets. For any file to be accessed from the assets, it must be decompressed. This is trivial for files that aren't video, but apparently due to the nature of video files, Android isn't able to decompress these files and play them. Therfore all video files must be stored on the real file system somewhere, and not in the APK.

+0

等等,真的嗎?在所有?這是記錄在任何地方? – Cheezmeister 2015-05-15 07:58:48

+0

@Cheezmeister我更新了我的答案。 – jgillich 2015-05-19 18:40:10

0

對於Android的嘗試使用「文件:///android_asset/www/path/video.webm」

但我認爲這個解決方案將不會在其他平臺上工作。