javascript Android 视频插件 Phonegap 与 Cordova 2.2.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14412957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android video Plugin Phonegap with Cordova 2.2.0
提问by Alessio Melani
I'm developing an application (a kind of social network for my university) and I have a problem with the Android video Player Phonegap plugin
我正在开发一个应用程序(一种适用于我大学的社交网络),但Android 视频播放器 Phonegap 插件出现问题
I have already do the 3 steps defined in the README to install the plugin but it doesn't work on my phone (Galaxy Ace Android 2.3.6) and on the emulator (4.0). I just load the Javascript (video.js) after (cordova.js) I have this error:
我已经执行了 README 中定义的 3 个步骤来安装插件,但它在我的手机(Galaxy Ace Android 2.3.6)和模拟器(4.0)上不起作用。我只是在 (cordova.js) 之后加载 Javascript (video.js) 我有这个错误:
Uncaught Function required the first argument! At cordova 2.2.0.js
未捕获的函数需要第一个参数!在科尔多瓦 2.2.0.js
It seems that video.js has a problem to use cordova.js. And when I tap the play button I have another error:
好像video.js 使用cordova.js 有问题。当我点击播放按钮时,我有另一个错误:
Uncaught Type Error: Cannot read property 'videoPlayer'
未捕获的类型错误:无法读取属性“videoPlayer”
And in this case it seems that video.js has not created a video Player object...
在这种情况下,video.js 似乎还没有创建视频播放器对象......
The code of my page is the same as the example on github:
我的页面代码和github上的例子一样:
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=yes" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
<script type="text/javascript" charset="utf-8" src="script/video.js"></script>
<script type="text/javascript">
function init(){
document.addEventListener("deviceready", console.log('ready'), true);
}
function playVideo(vidUrl) {
window.plugins.videoPlayer.play(vidUrl);
}
</script>
</head>
<body onload="init();">
<a href="#" onclick="playVideo('http_link')">Play HTTP</a>
</body>
Thanks to all.
谢谢大家。
回答by Simon MacDonald
I just made a code change to the VideoPlayer which should make it backward compatible with the old window.plugins.videoPlayer way of doing things. If you are using the 2.2.0 version of the plugin go get the new JS file.
我刚刚对 VideoPlayer 进行了代码更改,这应该使它与旧的 window.plugins.videoPlayer 做事方式向后兼容。如果您使用的是 2.2.0 版本的插件,请获取新的 JS 文件。
https://github.com/macdonst/VideoPlayer/blob/master/2.2.0/www/video.js
https://github.com/macdonst/VideoPlayer/blob/master/2.2.0/www/video.js
回答by jigspatel
if you add this
如果你添加这个
<plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>
to plugins.xml in res/xml folder.
到 res/xml 文件夹中的 plugins.xml。
then check code
然后检查代码
window.plugins.videoPlayer.play("https://www.youtube.com/watch?v=en_sVVjWFKk");
define two line in index.html
在 index.html 中定义两行
<script type="text/javascript" src="cordova-2.3.0.js"></script>
<script type="text/javascript" charset="utf-8" src="video.js"></script>
回答by krusk8
THe best way to reproduce Video with html is with Tag of HTML5.
使用 html 重现视频的最佳方法是使用 HTML5 标签。
Not all browser spport this, you have to try to Know!
并非所有浏览器都支持此功能,您必须尝试了解!