如何在 WP7 - Phonegap 中播放嵌入视频?
我需要在 WP7 PhoneGap 应用程序中播放嵌入的视频文件。文件 (dizzy.mp4) 位于 www 文件夹中,布局如下。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>PhoneGap WP7</title>
<link rel="stylesheet" href="master.css" type="text/css" />
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery-1.6.4.min.js"></script>
</head>
<body>
<video onclick="play()">
<source src="http://html5demos.com/assets/dizzy.mp4" type="video/mp4" />
</video>
<video onclick="play()">
<source src="./dizzy.mp4" type="video/mp4" />
</video>
</body>
</html>
如果单击第一个视频元素,则正在从 Internet 下载视频文件,一切正常。但是,单击第二个(本地视频)后,只会出现一个带有“正在打开...”标签的视频播放器屏幕。两个视频是同一个视频文件。
该应用程序在模拟器和真实设备(Nokia Lumnia 710 和 WF7.5 Mango)上运行,结果是相同的。
我尝试为视频文件设置不同的构建操作:内容、资源、嵌入资源。这没有帮助。
如何让它发挥作用?
更新:描述了类似的问题在这里。这是WP7的bug吗?
I need to play an embedded video file in my WP7 phonegap application. The file (dizzy.mp4) is located in the www folder along with the following layout
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>PhoneGap WP7</title>
<link rel="stylesheet" href="master.css" type="text/css" />
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery-1.6.4.min.js"></script>
</head>
<body>
<video onclick="play()">
<source src="http://html5demos.com/assets/dizzy.mp4" type="video/mp4" />
</video>
<video onclick="play()">
<source src="./dizzy.mp4" type="video/mp4" />
</video>
</body>
</html>
If the first video element is clicked, the video file is being downloaded from the Internet and all is ok. But after clicking on the second (local video) just a video player screen with 'Opening...' label appears. Both videos are the same video file.
The app was run both on an emulator and on a real device (Nokia Lumnia 710 with WF7.5 Mango), the result is the same.
I tried to set different build actions to the video file: Content, Resource, Embedded Resource. It doesn't help.
How to make it work?
UPDATE: A similar issue is described here. Is it a WP7 bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个解决方法。以下代码是实现视频播放功能的Phonegap命令。
这里只有播放功能,但可以扩展支持停止/暂停/关闭等。
在客户端注册该命令:
播放文件:
注意路径“/app/www/dizzy.mp4”。
Here is a workaround. The following code is a Phonegap command that implements video play back functionality.
There is only the Play function here, but it can be extended to support Stop/Pause/Close ect.
To register this command on client side:
To play back the file:
Pay attention to the path '/app/www/dizzy.mp4'.
我用PhoneGap实现了Android平台上播放音乐的功能,代码截图如下:
HTML 代码:
JavaScript 代码:
我认为您可以更改视频“src”路径,然后重试。如果应用仍然无法运行,您可以尝试调用phonegap media API来实现。
I implemented the functions of play music on Android platform with PhoneGap, and my code snapshot as below:
HTML code:
JavaScript code:
And I think you can change your video "src" path, and try again. If the app still doesn't work, you can try to call the phonegap media API for implementation.