科尔多瓦3.4的Android本地视频文件不玩 [英] Cordova 3.4 Android Local Video files not playing
问题描述
我已经尝试了好几天,现在通过科尔多瓦3.4应用程序,以发挥在我的Galaxy Tab 4.2的本地视频文件。
I have tried for days now to play a local video file on my galaxy tab 4.2 through a cordova 3.4 app.
当我使用绝对HTTP URL视频播放就好了。
When i use an absolute http url the video plays just fine.
下面是我曾尝试:
-
我把资产/ RES /原始文件夹中的视频文件,如下建议:的加载视频失败对HTML5的PhoneGap
结果:经过我点击播放 - >纺加载图标没有视频
RESULT: After i click on play -> spinning loading icon no video
- 视频在www文件夹:
- Video in the www folder:
结果:同#1
<video id="myvideo" controls="controls" width="400">
<source src="file:///android_asset/www/gruppenruf.mp4" />
</video>
结果:同#1
Result: Same as #1
我设置的文件夹中的所有权限为777
I set all the permissions of the folders to 777
然后我试图与 https://github.com/jaeger25/Html5Video 插件
安装插件后我得到的是: 03-06 18:27:06.953:E / Web控制台(22530):未捕获的类型错误:无法读取属性html5Video的不确定:37
After installing the plugin all i get is: 03-06 18:27:06.953: E/Web Console(22530): Uncaught TypeError: Cannot read property 'html5Video' of undefined:37
所有我试图做的是对Android的播放本地的视频文件。这是真的那么复杂吗?
All i am trying to do is play a local video file on android. Is this really that complicated?
任何帮助将是AP preciated。
any help would be appreciated.
推荐答案
看看<一href="http://stackoverflow.com/questions/26217509/cordova-3-6-3-file-plugin-get-local-video-file-on-android">this职位。 该文件的插件(至少&LT; = V1.3.1)的Android设备中的错误。另外,我不知道,如果jaeger25 / Html5Video插件还在工作与科尔多瓦3.6.x的。
Take a look at this post. The File plugin (at least <=v1.3.1) has a bug for android devices. Also, I am not sure if jaeger25/Html5Video plugin is still working with cordova 3.6.x.
一个工作方法是从 WWW / gruppenruf.mp4
运行时以编程方式复制您的视频文件播放到达的地方的应用程序。您可以使用文件:///data/data/com.example.MyPackage/files/gruppenruf.mp4
为。该文件传输科尔多瓦插件会照顾这一点。
A working approach is to programmatically copy your video files from www/gruppenruf.mp4
to a place accessible for playback by the app during runtime. You may use file:///data/data/com.example.MyPackage/files/gruppenruf.mp4
for that. The FileTransfer cordova plugin will take care of this.
var myFilename = "gruppenruf.mp4";
var myUrl = cordova.file.applicationDirectory + "www/" + myFilename;
var fileTransfer = new FileTransfer();
var filePath = cordova.file.dataDirectory + myFilename;
fileTransfer.download(encodeURI(myUrl), filePath, (function(entry) {
/*
res = "download complete:\n"
res += "fullPath: " + entry.fullPath + "\n"
res += "localURL: " + entry.localURL + "\n"
alert(res += "nativeURL: " + entry.nativeURL + "\n")
*/
var vid = document.getElementById("myvideo");
vid.src = entry.nativeURL;
//vid.loop = true;
}), (function(error) {
alert("Video download error: source " + error.source);
alert("Video download error: target " + error.target);
}), true, {
headers: {
Authorization: "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
});
如果它不打你可能要一个click事件侦听器链接到它,或者以 vid.play()的视频。
If it does not play you may want to link a click event listener to it or start the video with vid.play();
.
这篇关于科尔多瓦3.4的Android本地视频文件不玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!